
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/polys/reference.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:52 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Polynomials Manipulation Module Reference &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="reference.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="AGCA - Algebraic Geometry and Commutative Algebra Module" href="agca.html" />
    <link rel="prev" title="Examples from Wester’s Article" href="wester.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="agca.html" title="AGCA - Algebraic Geometry and Commutative Algebra Module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="wester.html" title="Examples from Wester’s Article"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Polynomial Manipulation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Polynomials Manipulation Module Reference</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.polys">
<span id="polynomials-manipulation-module-reference"></span><span id="polys-reference"></span><h1>Polynomials Manipulation Module Reference<a class="headerlink" href="#module-sympy.polys" title="Permalink to this headline">¶</a></h1>
<p>Polynomial manipulation algorithms and algebraic objects.</p>
<p>See <a class="reference internal" href="index.html#polys-docs"><span class="std std-ref">Polynomial Manipulation</span></a> for an index of documentation for the polys module and
<a class="reference internal" href="basics.html#polys-basics"><span class="std std-ref">Basic functionality of the module</span></a> for an introductory explanation.</p>
<section id="basic-polynomial-manipulation-functions">
<h2>Basic polynomial manipulation functions<a class="headerlink" href="#basic-polynomial-manipulation-functions" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L7150-L7229"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently transform an expression into a polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x**5 + 2*x**4 - x**3 - 2*x**2 + x, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.poly_from_expr">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">poly_from_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4289-L4293"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.poly_from_expr" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial from an expression.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.parallel_poly_from_expr">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">parallel_poly_from_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">exprs</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4336-L4340"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.parallel_poly_from_expr" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct polynomials from expressions.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.degree">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">degree</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gen</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4448-L4504"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.degree" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the degree of <code class="docutils literal notranslate"><span class="pre">f</span></code> in the given variable.</p>
<p>The degree of 0 is negative infinity.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">degree</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">degree</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">gen</span><span class="o">=</span><span class="n">x</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">degree</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">gen</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">degree</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">-oo</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.total_degree" title="sympy.polys.polytools.Poly.total_degree"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.polys.polytools.Poly.total_degree</span></code></a>, <a class="reference internal" href="#sympy.polys.polytools.degree_list" title="sympy.polys.polytools.degree_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">degree_list</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.degree_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">degree_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4560-L4584"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.degree_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of degrees of <code class="docutils literal notranslate"><span class="pre">f</span></code> in all variables.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">degree_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">degree_list</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">(2, 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.LC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">LC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4587-L4609"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.LC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">LC</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">LC</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.LM">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">LM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4612-L4635"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.LM" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading monomial of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">LM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">LM</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">x**2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.LT">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">LT</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4638-L4661"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.LT" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading term of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">LT</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">LT</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">4*x**2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.pdiv">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">pdiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4664-L4691"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.pdiv" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial pseudo-division of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">pdiv</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pdiv</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">(2*x + 4, 20)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.prem">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">prem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4694-L4721"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.prem" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial pseudo-remainder of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">prem</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">prem</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">20</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.pquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">pquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4724-L4756"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.pquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial pseudo-quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">pquo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pquo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">2*x + 4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pquo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">2*x + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.pexquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">pexquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4759-L4791"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.pexquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial exact pseudo-quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">pexquo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pexquo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">2*x + 2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pexquo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">2*x - 4 does not divide x**2 + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.div">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4794-L4823"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.div" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial division of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">div</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">div</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">ZZ</span><span class="p">)</span>
<span class="go">(0, x**2 + 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">div</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">QQ</span><span class="p">)</span>
<span class="go">(x/2 + 1, 5)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.rem">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">rem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4826-L4855"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.rem" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial remainder of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">rem</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">rem</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">ZZ</span><span class="p">)</span>
<span class="go">x**2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rem</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">QQ</span><span class="p">)</span>
<span class="go">5</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.quo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">quo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4858-L4887"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.quo" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">quo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">quo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">x/2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">quo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.exquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">exquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4890-L4922"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.exquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial exact quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">exquo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">exquo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x + 1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">exquo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">2*x - 4 does not divide x**2 + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.half_gcdex">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">half_gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4925-L4961"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.half_gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Half extended Euclidean algorithm of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(s,</span> <span class="pre">h)</span></code> such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code> and <code class="docutils literal notranslate"><span class="pre">s*f</span> <span class="pre">=</span> <span class="pre">h</span> <span class="pre">(mod</span> <span class="pre">g)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">half_gcdex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">half_gcdex</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">15</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">(3/5 - x/5, x + 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.gcdex">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4964-L5000"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Extended Euclidean algorithm of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(s,</span> <span class="pre">t,</span> <span class="pre">h)</span></code> such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code> and <code class="docutils literal notranslate"><span class="pre">s*f</span> <span class="pre">+</span> <span class="pre">t*g</span> <span class="pre">=</span> <span class="pre">h</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">gcdex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gcdex</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">15</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">(3/5 - x/5, x**2/5 - 6*x/5 + 2, x + 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.invert">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">invert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5003-L5054"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.invert" title="Permalink to this definition">¶</a></dt>
<dd><p>Invert <code class="docutils literal notranslate"><span class="pre">f</span></code> modulo <code class="docutils literal notranslate"><span class="pre">g</span></code> when possible.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">invert</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.core.numbers</span> <span class="kn">import</span> <span class="n">mod_inverse</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">invert</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">-4/3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">invert</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">NotInvertible</span>: <span class="n">zero divisor</span>
</pre></div>
</div>
<p>For more efficient inversion of Rationals,
use the <a class="reference internal" href="../core.html#sympy.core.numbers.mod_inverse" title="sympy.core.numbers.mod_inverse"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mod_inverse</span></code></a> function:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">mod_inverse</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">(</span><span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">5</span><span class="p">)</span><span class="o">.</span><span class="n">invert</span><span class="p">(</span><span class="n">S</span><span class="p">(</span><span class="mi">7</span><span class="p">)</span><span class="o">/</span><span class="mi">3</span><span class="p">)</span>
<span class="go">5/2</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../core.html#sympy.core.numbers.mod_inverse" title="sympy.core.numbers.mod_inverse"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.core.numbers.mod_inverse</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.subresultants">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">subresultants</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5057-L5084"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.subresultants" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute subresultant PRS of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">subresultants</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">subresultants</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[x**2 + 1, x**2 - 1, -2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.resultant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">includePRS</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5087-L5121"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute resultant of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">resultant</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">resultant</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.discriminant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">discriminant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5124-L5151"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.discriminant" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute discriminant of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">discriminant</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">discriminant</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">-8</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.terms_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">terms_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5461-L5577"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.terms_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove GCD of terms from <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">deep</span></code> flag is True, then the arguments of <code class="docutils literal notranslate"><span class="pre">f</span></code> will have
terms_gcd applied to them.</p>
<p>If a fraction is factored out of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">f</span></code> is an Add, then
an unevaluated Mul will be returned so that automatic simplification
does not redistribute it. The hint <code class="docutils literal notranslate"><span class="pre">clear</span></code>, when set to False, can be
used to prevent such factoring when all coefficients are not fractions.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">terms_gcd</span><span class="p">,</span> <span class="n">cos</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">6</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">x**3*y*(x**3*y + 1)</span>
</pre></div>
</div>
<p>The default action of polys routines is to expand the expression
given to them. terms_gcd follows this behavior:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">((</span><span class="mi">3</span><span class="o">+</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span><span class="o">+</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">))</span>
<span class="go">3*x*(x*y + x + y + 1)</span>
</pre></div>
</div>
<p>If this is not desired then the hint <code class="docutils literal notranslate"><span class="pre">expand</span></code> can be set to False.
In this case the expression will be treated as though it were comprised
of one or more terms:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">((</span><span class="mi">3</span><span class="o">+</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span><span class="o">+</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">),</span> <span class="n">expand</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">(3*x + 3)*(x*y + x)</span>
</pre></div>
</div>
<p>In order to traverse factors of a Mul or the arguments of other
functions, the <code class="docutils literal notranslate"><span class="pre">deep</span></code> hint can be used:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">((</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">),</span> <span class="n">expand</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">deep</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">3*x*(x + 1)*(y + 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">),</span> <span class="n">deep</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">cos(x*(y + 1))</span>
</pre></div>
</div>
<p>Rationals are factored out by default:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="go">(2*x + y)/2</span>
</pre></div>
</div>
<p>Only the y-term had a coefficient that was a fraction; if one
does not want to factor out the 1/2 in cases like this, the
flag <code class="docutils literal notranslate"><span class="pre">clear</span></code> can be set to False:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">clear</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">x + y/2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">clear</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">y*(x/2 + y)</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">clear</span></code> flag is ignored if all coefficients are fractions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">terms_gcd</span><span class="p">(</span><span class="n">x</span><span class="o">/</span><span class="mi">3</span> <span class="o">+</span> <span class="n">y</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">clear</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">(2*x + 3*y)/6</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../core.html#sympy.core.exprtools.gcd_terms" title="sympy.core.exprtools.gcd_terms"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.core.exprtools.gcd_terms</span></code></a>, <a class="reference internal" href="../core.html#sympy.core.exprtools.factor_terms" title="sympy.core.exprtools.factor_terms"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.core.exprtools.factor_terms</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.cofactors">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">cofactors</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5154-L5192"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.cofactors" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute GCD and cofactors of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>Returns polynomials <code class="docutils literal notranslate"><span class="pre">(h,</span> <span class="pre">cff,</span> <span class="pre">cfg)</span></code> such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code>, and
<code class="docutils literal notranslate"><span class="pre">cff</span> <span class="pre">=</span> <span class="pre">quo(f,</span> <span class="pre">h)</span></code> and <code class="docutils literal notranslate"><span class="pre">cfg</span> <span class="pre">=</span> <span class="pre">quo(g,</span> <span class="pre">h)</span></code> are, so called, cofactors
of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">cofactors</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cofactors</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(x - 1, x + 1, x - 2)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5280-L5329"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute GCD of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">gcd</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gcd</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x - 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.gcd_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">gcd_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seq</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5195-L5277"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.gcd_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute GCD of a list of polynomials.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">gcd_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gcd_list</span><span class="p">([</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">])</span>
<span class="go">x - 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.lcm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">lcm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5410-L5458"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.lcm" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute LCM of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">lcm</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">lcm</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**3 - 2*x**2 - x + 2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.lcm_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">lcm_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seq</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5332-L5407"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.lcm_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute LCM of a list of polynomials.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">lcm_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">lcm_list</span><span class="p">([</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">])</span>
<span class="go">x**5 - x**4 - 2*x**3 - x**2 + x + 2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.trunc">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">trunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5580-L5607"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.trunc" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce <code class="docutils literal notranslate"><span class="pre">f</span></code> modulo a constant <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">trunc</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">trunc</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">-x**3 - x + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.monic">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">monic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5610-L5637"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.monic" title="Permalink to this definition">¶</a></dt>
<dd><p>Divide all coefficients of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">LC(f)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">monic</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">monic</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**2 + 4*x/3 + 2/3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.content">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">content</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5640-L5662"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.content" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute GCD of coefficients of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">content</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">content</span><span class="p">(</span><span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.primitive">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">primitive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5665-L5708"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.primitive" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute content and the primitive form of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polytools</span> <span class="kn">import</span> <span class="n">primitive</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">primitive</span><span class="p">(</span><span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">)</span>
<span class="go">(2, 3*x**2 + 4*x + 6)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="p">(</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<p>Expansion is performed by default:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">primitive</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="go">(2, x**2 + x + 1)</span>
</pre></div>
</div>
<p>Set <code class="docutils literal notranslate"><span class="pre">expand</span></code> to False to shut this off. Note that the
extraction will not be recursive; use the as_content_primitive method
for recursive, non-destructive Rational extraction.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">primitive</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">expand</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">(1, x*(2*x + 2) + 2)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span><span class="o">.</span><span class="n">as_content_primitive</span><span class="p">()</span>
<span class="go">(2, x*(x + 1) + 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.compose">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">compose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5711-L5738"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.compose" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute functional composition <code class="docutils literal notranslate"><span class="pre">f(g)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">compose</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">compose</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x**2 - x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.decompose">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">decompose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5741-L5768"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.decompose" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute functional decomposition of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">decompose</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">decompose</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[x**2 - x - 1, x**2 + x]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.sturm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">sturm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5771-L5798"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.sturm" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute Sturm sequence of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sturm</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sturm</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">[x**3 - 2*x**2 + x - 3, 3*x**2 - 4*x + 1, 2*x/9 + 25/9, -2079/4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.gff_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">gff_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5801-L5845"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.gff_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute a list of greatest factorial factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>Note that the input to ff() and rf() should be Poly instances to use the
definitions here.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">gff_list</span><span class="p">,</span> <span class="n">ff</span><span class="p">,</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gff_list</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">[(Poly(x, x, domain=&#39;ZZ&#39;), 1), (Poly(x + 2, x, domain=&#39;ZZ&#39;), 4)]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">(</span><span class="n">ff</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="mi">1</span><span class="p">)</span><span class="o">*</span><span class="n">ff</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">),</span> <span class="mi">4</span><span class="p">))</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">12</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">11</span> <span class="o">-</span> <span class="mi">11</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="mi">56</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">9</span> <span class="o">+</span> <span class="mi">220</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">8</span> <span class="o">+</span> <span class="mi">208</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">7</span> <span class="o">-</span>         <span class="mi">1401</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">+</span> <span class="mi">1090</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2715</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">6720</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">1092</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5040</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gff_list</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">[(Poly(x**3 + 7, x, domain=&#39;ZZ&#39;), 2), (Poly(x**2 + 5*x, x, domain=&#39;ZZ&#39;), 3)]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ff</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">7</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">ff</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="mi">3</span><span class="p">)</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.gff">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">gff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5848-L5851"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.gff" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute greatest factorial factorization of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.sqf_norm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">sqf_norm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5854-L5885"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.sqf_norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute square-free norm of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">s</span></code>, <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">r</span></code>, such that <code class="docutils literal notranslate"><span class="pre">g(x)</span> <span class="pre">=</span> <span class="pre">f(x-sa)</span></code> and
<code class="docutils literal notranslate"><span class="pre">r(x)</span> <span class="pre">=</span> <span class="pre">Norm(g(x))</span></code> is a square-free polynomial over <code class="docutils literal notranslate"><span class="pre">K</span></code>,
where <code class="docutils literal notranslate"><span class="pre">a</span></code> is the algebraic extension of the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqf_norm</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sqf_norm</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="p">[</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">)])</span>
<span class="go">(1, x**2 - 2*sqrt(3)*x + 4, x**4 - 4*x**2 + 16)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.sqf_part">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">sqf_part</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L5888-L5915"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.sqf_part" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute square-free part of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqf_part</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sqf_part</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**2 - x - 2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.sqf_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">sqf_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6238-L6253"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.sqf_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute a list of square-free factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqf_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sqf_list</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">16</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">50</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">76</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">56</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">16</span><span class="p">)</span>
<span class="go">(2, [(x + 1, 2), (x + 2, 3)])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.sqf">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">sqf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6256-L6271"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.sqf" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute square-free factorization of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqf</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sqf</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">16</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">50</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">76</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">56</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">16</span><span class="p">)</span>
<span class="go">2*(x + 1)**2*(x + 2)**3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.factor_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">factor_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6274-L6289"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.factor_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute a list of irreducible factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">factor_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor_list</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">(2, [(x + y, 1), (x**2 + 1, 2)])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">deep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6292-L6390"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the factorization of expression, <code class="docutils literal notranslate"><span class="pre">f</span></code>, into irreducibles. (To
factor an integer into primes, use <code class="docutils literal notranslate"><span class="pre">factorint</span></code>.)</p>
<p>There two modes implemented: symbolic and formal. If <code class="docutils literal notranslate"><span class="pre">f</span></code> is not an
instance of <a class="reference internal" href="#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-class docutils literal notranslate"><span class="pre">Poly</span></code></a> and generators are not specified, then the
former mode is used. Otherwise, the formal mode is used.</p>
<p>In symbolic mode, <a class="reference internal" href="#sympy.polys.polytools.factor" title="sympy.polys.polytools.factor"><code class="xref py py-func docutils literal notranslate"><span class="pre">factor()</span></code></a> will traverse the expression tree and
factor its components without any prior expansion, unless an instance
of <a class="reference internal" href="../core.html#sympy.core.add.Add" title="sympy.core.add.Add"><code class="xref py py-class docutils literal notranslate"><span class="pre">Add</span></code></a> is encountered (in this case formal factorization is
used). This way <a class="reference internal" href="#sympy.polys.polytools.factor" title="sympy.polys.polytools.factor"><code class="xref py py-func docutils literal notranslate"><span class="pre">factor()</span></code></a> can handle large or symbolic exponents.</p>
<p>By default, the factorization is computed over the rationals. To factor
over other domain, e.g. an algebraic or finite field, use appropriate
options: <code class="docutils literal notranslate"><span class="pre">extension</span></code>, <code class="docutils literal notranslate"><span class="pre">modulus</span></code> or <code class="docutils literal notranslate"><span class="pre">domain</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">factor</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">exp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">2*(x + y)*(x**2 + 1)**2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x**2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">modulus</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">(x + 1)**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">gaussian</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(x - I)*(x + I)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">(x - sqrt(2))*(x + sqrt(2))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">(x - 1)*(x + 1)/(x + 2)**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">**</span><span class="mi">10000000</span><span class="o">*</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">(x + 2)**20000000*(x**2 + 1)</span>
</pre></div>
</div>
<p>By default, factor deals with an expression as a whole:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="mi">2</span><span class="o">**</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="go">2**(x**2 + 2*x + 1)</span>
</pre></div>
</div>
<p>If the <code class="docutils literal notranslate"><span class="pre">deep</span></code> flag is True then subexpressions will
be factored:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">deep</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">2**((x + 1)**2)</span>
</pre></div>
</div>
<p>If the <code class="docutils literal notranslate"><span class="pre">fraction</span></code> flag is False then rational expressions
won’t be combined. By default it is True.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="mi">5</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">deep</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(5*x*exp(7*x) + 3*exp(2))*exp(-7*x)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">factor</span><span class="p">(</span><span class="mi">5</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">deep</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">fraction</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">5*x + 3*exp(2)*exp(-7*x)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../ntheory.html#sympy.ntheory.factor_.factorint" title="sympy.ntheory.factor_.factorint"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.ntheory.factor_.factorint</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.intervals">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">intervals</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strict</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fast</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sqf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6393-L6446"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.intervals" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute isolating intervals for roots of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">intervals</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">intervals</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">[((-2, -1), 1), ((1, 2), 1)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">intervals</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="mf">1e-2</span><span class="p">)</span>
<span class="go">[((-26/15, -19/11), 1), ((19/11, 26/15), 1)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.refine_root">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">refine_root</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">t</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fast</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">check_sqf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6449-L6475"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.refine_root" title="Permalink to this definition">¶</a></dt>
<dd><p>Refine an isolating interval of a root to the given precision.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">refine_root</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">refine_root</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="mf">1e-2</span><span class="p">)</span>
<span class="go">(19/11, 26/15)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.count_roots">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">count_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6478-L6508"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.count_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the number of roots of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">[inf,</span> <span class="pre">sup]</span></code> interval.</p>
<p>If one of <code class="docutils literal notranslate"><span class="pre">inf</span></code> or <code class="docutils literal notranslate"><span class="pre">sup</span></code> is complex, it will return the number of roots
in the complex rectangle with corners at <code class="docutils literal notranslate"><span class="pre">inf</span></code> and <code class="docutils literal notranslate"><span class="pre">sup</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">count_roots</span><span class="p">,</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">count_roots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">count_roots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">I</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.real_roots">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">real_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">multiple</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6511-L6536"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.real_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of real roots with multiplicities of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">real_roots</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">real_roots</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">[-1/2, 2, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.nroots">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">nroots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxsteps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">50</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cleanup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6539-L6567"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.nroots" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute numerical approximations of roots of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">nroots</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">nroots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
<span class="go">[-1.73205080756888, 1.73205080756888]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">nroots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
<span class="go">[-1.73205080756887729352744634151, 1.73205080756887729352744634151]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.ground_roots">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">ground_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6570-L6597"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.ground_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute roots of <code class="docutils literal notranslate"><span class="pre">f</span></code> by factorization in the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ground_roots</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ground_roots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">{0: 2, 1: 2}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.nth_power_roots_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">nth_power_roots_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6600-L6641"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.nth_power_roots_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial with n-th powers of roots of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">nth_power_roots_poly</span><span class="p">,</span> <span class="n">factor</span><span class="p">,</span> <span class="n">roots</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">factor</span><span class="p">(</span><span class="n">nth_power_roots_poly</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">g</span>
<span class="go">(x**2 - x + 1)**2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R_f</span> <span class="o">=</span> <span class="p">[</span> <span class="p">(</span><span class="n">r</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">expand</span><span class="p">()</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">roots</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R_g</span> <span class="o">=</span> <span class="n">roots</span><span class="p">(</span><span class="n">g</span><span class="p">)</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">set</span><span class="p">(</span><span class="n">R_f</span><span class="p">)</span> <span class="o">==</span> <span class="nb">set</span><span class="p">(</span><span class="n">R_g</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.cancel">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">cancel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6644-L6742"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel common factors in a rational function <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">cancel</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">together</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;A&#39;</span><span class="p">,</span> <span class="n">commutative</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cancel</span><span class="p">((</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">(2*x + 2)/(x - 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cancel</span><span class="p">((</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">15</span><span class="p">)</span><span class="o">*</span><span class="n">A</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">*</span><span class="n">A</span><span class="p">))</span>
<span class="go">sqrt(6)/2</span>
</pre></div>
</div>
<p>Note: due to automatic distribution of Rationals, a sum divided by an integer
will appear as a sum. To recover a rational form use <span class="math notranslate nohighlight">\(together\)</span> on the result:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cancel</span><span class="p">(</span><span class="n">x</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x/2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="n">_</span><span class="p">)</span>
<span class="go">(x + 2)/2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.reduced">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">reduced</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6745-L6802"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.reduced" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduces a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> modulo a set of polynomials <code class="docutils literal notranslate"><span class="pre">G</span></code>.</p>
<p>Given a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> and a set of polynomials <code class="docutils literal notranslate"><span class="pre">G</span> <span class="pre">=</span> <span class="pre">(g_1,</span> <span class="pre">...,</span> <span class="pre">g_n)</span></code>,
computes a set of quotients <code class="docutils literal notranslate"><span class="pre">q</span> <span class="pre">=</span> <span class="pre">(q_1,</span> <span class="pre">...,</span> <span class="pre">q_n)</span></code> and the remainder <code class="docutils literal notranslate"><span class="pre">r</span></code>
such that <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">q_1*g_1</span> <span class="pre">+</span> <span class="pre">...</span> <span class="pre">+</span> <span class="pre">q_n*g_n</span> <span class="pre">+</span> <span class="pre">r</span></code>, where <code class="docutils literal notranslate"><span class="pre">r</span></code> vanishes or <code class="docutils literal notranslate"><span class="pre">r</span></code>
is a completely reduced polynomial with respect to <code class="docutils literal notranslate"><span class="pre">G</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">reduced</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">reduced</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span><span class="p">,</span> <span class="p">[</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">y</span><span class="p">])</span>
<span class="go">([2*x, 1], x**2 + y**2 + y)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.groebner">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">groebner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6805-L6856"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.groebner" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the reduced Groebner basis for a set of polynomials.</p>
<p>Use the <code class="docutils literal notranslate"><span class="pre">order</span></code> argument to set the monomial ordering that will be
used to compute the basis. Allowed orders are <code class="docutils literal notranslate"><span class="pre">lex</span></code>, <code class="docutils literal notranslate"><span class="pre">grlex</span></code> and
<code class="docutils literal notranslate"><span class="pre">grevlex</span></code>. If no order is specified, it defaults to <code class="docutils literal notranslate"><span class="pre">lex</span></code>.</p>
<p>For more information on Groebner bases, see the references and the docstring
of <a class="reference internal" href="../solvers/solvers.html#sympy.solvers.polysys.solve_poly_system" title="sympy.solvers.polysys.solve_poly_system"><code class="xref py py-func docutils literal notranslate"><span class="pre">solve_poly_system()</span></code></a>.</p>
<p class="rubric">Examples</p>
<p>Example taken from [1].</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">groebner</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">F</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;lex&#39;</span><span class="p">)</span>
<span class="go">GroebnerBasis([x**2 - 2*y**2, x*y - 2*y, y**3 - 2*y], x, y,</span>
<span class="go">              domain=&#39;ZZ&#39;, order=&#39;lex&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;grlex&#39;</span><span class="p">)</span>
<span class="go">GroebnerBasis([y**3 - 2*y, x**2 - 2*y**2, x*y - 2*y], x, y,</span>
<span class="go">              domain=&#39;ZZ&#39;, order=&#39;grlex&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;grevlex&#39;</span><span class="p">)</span>
<span class="go">GroebnerBasis([y**3 - 2*y, x**2 - 2*y**2, x*y - 2*y], x, y,</span>
<span class="go">              domain=&#39;ZZ&#39;, order=&#39;grevlex&#39;)</span>
</pre></div>
</div>
<p>By default, an improved implementation of the Buchberger algorithm is
used. Optionally, an implementation of the F5B algorithm can be used. The
algorithm can be set using the <code class="docutils literal notranslate"><span class="pre">method</span></code> flag or with the
<a class="reference internal" href="internals.html#sympy.polys.polyconfig.setup" title="sympy.polys.polyconfig.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">sympy.polys.polyconfig.setup()</span></code></a> function.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">F</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="n">y</span> <span class="o">-</span> <span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="mi">10</span><span class="p">)]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">&#39;buchberger&#39;</span><span class="p">)</span>
<span class="go">GroebnerBasis([x**2 - x - 1, y - 55], x, y, domain=&#39;ZZ&#39;, order=&#39;lex&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">&#39;f5b&#39;</span><span class="p">)</span>
<span class="go">GroebnerBasis([x**2 - x - 1, y - 55], x, y, domain=&#39;ZZ&#39;, order=&#39;lex&#39;)</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#buchberger01" id="id1"><span>[Buchberger01]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#cox97" id="id2"><span>[Cox97]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polytools.is_zero_dimensional">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">is_zero_dimensional</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6859-L6874"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.is_zero_dimensional" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if the ideal generated by a Groebner basis is zero-dimensional.</p>
<p>The algorithm checks if the set of monomials not divisible by the
leading monomial of any element of <code class="docutils literal notranslate"><span class="pre">F</span></code> is bounded.</p>
<p class="rubric">References</p>
<p>David A. Cox, John B. Little, Donal O’Shea. Ideals, Varieties and
Algorithms, 3rd edition, p. 230</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">Poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L89-L4192"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generic class for representing and operating on polynomial expressions.</p>
<p>See <a class="reference internal" href="index.html#polys-docs"><span class="std std-ref">Polynomial Manipulation</span></a> for general documentation.</p>
<p>Poly is a subclass of Basic rather than Expr but instances can be
converted to Expr with the <a class="reference internal" href="#sympy.polys.polytools.Poly.as_expr" title="sympy.polys.polytools.Poly.as_expr"><code class="xref py py-meth docutils literal notranslate"><span class="pre">as_expr()</span></code></a> method.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<p>Create a univariate polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x**5 + 2*x**4 - x**3 - 2*x**2 + x, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<p>Create a univariate polynomial with specific domain:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;R&#39;</span><span class="p">)</span>
<span class="go">Poly(1.0*x**2 + 2.0*x + 1.73205080756888, x, domain=&#39;RR&#39;)</span>
</pre></div>
</div>
<p>Create a multivariate polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">y</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">Poly(x**2*y + x*y + 1, x, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<p>Create a univariate polynomial, where y is a constant:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">y</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span><span class="n">x</span><span class="p">)</span>
<span class="go">Poly(y*x**2 + y*x + 1, x, domain=&#39;ZZ[y]&#39;)</span>
</pre></div>
</div>
<p>You can evaluate the above polynomial as a function of y:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">y</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">eval</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">6*y + 1</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../core.html#sympy.core.expr.Expr" title="sympy.core.expr.Expr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.core.expr.Expr</span></code></a></p>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.EC">
<span class="sig-name descname"><span class="pre">EC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2021-L2038"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.EC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the last non-zero coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">EC</span><span class="p">()</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.EM">
<span class="sig-name descname"><span class="pre">EM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2143-L2157"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.EM" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the last non-zero monomial of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">EM</span><span class="p">()</span>
<span class="go">x**0*y**1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.ET">
<span class="sig-name descname"><span class="pre">ET</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2180-L2195"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.ET" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the last non-zero term of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">ET</span><span class="p">()</span>
<span class="go">(x**0*y**1, 3)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.LC">
<span class="sig-name descname"><span class="pre">LC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1976-L1998"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.LC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the leading coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">LC</span><span class="p">()</span>
<span class="go">4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.LM">
<span class="sig-name descname"><span class="pre">LM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2123-L2141"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.LM" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the leading monomial of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>The Leading monomial signifies the monomial having
the highest power of the principal generator in the
expression f.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">LM</span><span class="p">()</span>
<span class="go">x**2*y**0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.LT">
<span class="sig-name descname"><span class="pre">LT</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2159-L2178"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.LT" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the leading term of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>The Leading term signifies the term having
the highest power of the principal generator in the
expression f along with its coefficient.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">LT</span><span class="p">()</span>
<span class="go">(x**2*y**0, 4)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.TC">
<span class="sig-name descname"><span class="pre">TC</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2000-L2019"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.TC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the trailing coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">TC</span><span class="p">()</span>
<span class="go">0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.abs">
<span class="sig-name descname"><span class="pre">abs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1366-L1385"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.abs" title="Permalink to this definition">¶</a></dt>
<dd><p>Make all coefficients in <code class="docutils literal notranslate"><span class="pre">f</span></code> positive.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">abs</span><span class="p">()</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.add">
<span class="sig-name descname"><span class="pre">add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1411-L1440"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add two polynomials <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x**2 + x - 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Poly(x**2 + x - 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.add_ground">
<span class="sig-name descname"><span class="pre">add_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">coeff</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1253-L1272"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.add_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an element of the ground domain to <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">add_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x + 3, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.all_coeffs">
<span class="sig-name descname"><span class="pre">all_coeffs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L916-L930"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.all_coeffs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all coefficients from a univariate polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">all_coeffs</span><span class="p">()</span>
<span class="go">[1, 0, 2, -1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.all_monoms">
<span class="sig-name descname"><span class="pre">all_monoms</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L932-L950"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.all_monoms" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all monomials from a univariate polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">all_monoms</span><span class="p">()</span>
<span class="go">[(3,), (2,), (1,), (0,)]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.all_terms" title="sympy.polys.polytools.Poly.all_terms"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_terms</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.all_roots">
<span class="sig-name descname"><span class="pre">all_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">multiple</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3599-L3622"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.all_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of real and complex roots with multiplicities.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">all_roots</span><span class="p">()</span>
<span class="go">[-1/2, 2, 2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">all_roots</span><span class="p">()</span>
<span class="go">[CRootOf(x**3 + x + 1, 0),</span>
<span class="go"> CRootOf(x**3 + x + 1, 1),</span>
<span class="go"> CRootOf(x**3 + x + 1, 2)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.all_terms">
<span class="sig-name descname"><span class="pre">all_terms</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L952-L966"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.all_terms" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all terms from a univariate polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">all_terms</span><span class="p">()</span>
<span class="go">[((3,), 1), ((2,), 0), ((1,), 2), ((0,), -1)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.as_dict">
<span class="sig-name descname"><span class="pre">as_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">native</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zero</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1021-L1038"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.as_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Switch to a <code class="docutils literal notranslate"><span class="pre">dict</span></code> representation.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
<span class="go">{(0, 1): -1, (1, 2): 2, (2, 0): 1}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.as_expr">
<span class="sig-name descname"><span class="pre">as_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1047-L1083"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.as_expr" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a Poly instance to an Expr instance.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">as_expr</span><span class="p">()</span>
<span class="go">x**2 + 2*x*y**2 - y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">as_expr</span><span class="p">({</span><span class="n">x</span><span class="p">:</span> <span class="mi">5</span><span class="p">})</span>
<span class="go">10*y**2 - y + 25</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">as_expr</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span>
<span class="go">379</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.as_list">
<span class="sig-name descname"><span class="pre">as_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">native</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1040-L1045"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.as_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Switch to a <code class="docutils literal notranslate"><span class="pre">list</span></code> representation.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.as_poly">
<span class="sig-name descname"><span class="pre">as_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1085-L1109"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.as_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts <code class="docutils literal notranslate"><span class="pre">self</span></code> to a polynomial or returns <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sin</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">as_poly</span><span class="p">())</span>
<span class="go">Poly(x**2 + x*y, x, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">as_poly</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>
<span class="go">Poly(x**2 + x*y, x, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sin</span><span class="p">(</span><span class="n">y</span><span class="p">))</span><span class="o">.</span><span class="n">as_poly</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>
<span class="go">None</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.cancel">
<span class="sig-name descname"><span class="pre">cancel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3765-L3800"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel common factors in a rational function <code class="docutils literal notranslate"><span class="pre">f/g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">cancel</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">(1, Poly(2*x + 2, x, domain=&#39;ZZ&#39;), Poly(x - 1, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">cancel</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="n">include</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(Poly(2*x + 2, x, domain=&#39;ZZ&#39;), Poly(x - 1, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.clear_denoms">
<span class="sig-name descname"><span class="pre">clear_denoms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">convert</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2239-L2276"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.clear_denoms" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear denominators, but keep the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">clear_denoms</span><span class="p">()</span>
<span class="go">(6, Poly(3*x + 2, x, domain=&#39;QQ&#39;))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">clear_denoms</span><span class="p">(</span><span class="n">convert</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(6, Poly(3*x + 2, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.coeff_monomial">
<span class="sig-name descname"><span class="pre">coeff_monomial</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">monom</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2040-L2075"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.coeff_monomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the coefficient of <code class="docutils literal notranslate"><span class="pre">monom</span></code> in <code class="docutils literal notranslate"><span class="pre">f</span></code> if there, else None.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">exp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="mi">24</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span> <span class="o">+</span> <span class="mi">23</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">coeff_monomial</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">23</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">coeff_monomial</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">coeff_monomial</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">24*exp(8)</span>
</pre></div>
</div>
<p>Note that <code class="docutils literal notranslate"><span class="pre">Expr.coeff()</span></code> behaves differently, collecting terms
if possible; the Poly must be converted to an Expr to use that
method, however:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">as_expr</span><span class="p">()</span><span class="o">.</span><span class="n">coeff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">24*y*exp(8) + 23</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">as_expr</span><span class="p">()</span><span class="o">.</span><span class="n">coeff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="go">24*x*exp(8)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">as_expr</span><span class="p">()</span><span class="o">.</span><span class="n">coeff</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">24*exp(8)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#sympy.polys.polytools.Poly.nth" title="sympy.polys.polytools.Poly.nth"><code class="xref py py-obj docutils literal notranslate"><span class="pre">nth</span></code></a></dt><dd><p>more efficient query using exponents of the monomial’s generators</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.coeffs">
<span class="sig-name descname"><span class="pre">coeffs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L854-L874"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.coeffs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all non-zero coefficients from <code class="docutils literal notranslate"><span class="pre">f</span></code> in lex order.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">coeffs</span><span class="p">()</span>
<span class="go">[1, 2, 3]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.all_coeffs" title="sympy.polys.polytools.Poly.all_coeffs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_coeffs</span></code></a>, <a class="reference internal" href="#sympy.polys.polytools.Poly.coeff_monomial" title="sympy.polys.polytools.Poly.coeff_monomial"><code class="xref py py-obj docutils literal notranslate"><span class="pre">coeff_monomial</span></code></a>, <a class="reference internal" href="#sympy.polys.polytools.Poly.nth" title="sympy.polys.polytools.Poly.nth"><code class="xref py py-obj docutils literal notranslate"><span class="pre">nth</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.cofactors">
<span class="sig-name descname"><span class="pre">cofactors</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2856-L2883"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.cofactors" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the GCD of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> and their cofactors.</p>
<p>Returns polynomials <code class="docutils literal notranslate"><span class="pre">(h,</span> <span class="pre">cff,</span> <span class="pre">cfg)</span></code> such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code>, and
<code class="docutils literal notranslate"><span class="pre">cff</span> <span class="pre">=</span> <span class="pre">quo(f,</span> <span class="pre">h)</span></code> and <code class="docutils literal notranslate"><span class="pre">cfg</span> <span class="pre">=</span> <span class="pre">quo(g,</span> <span class="pre">h)</span></code> are, so called, cofactors
of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">cofactors</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">(Poly(x - 1, x, domain=&#39;ZZ&#39;),</span>
<span class="go"> Poly(x + 1, x, domain=&#39;ZZ&#39;),</span>
<span class="go"> Poly(x - 2, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.compose">
<span class="sig-name descname"><span class="pre">compose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3025-L3046"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.compose" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the functional composition of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">compose</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x**2 - x, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.content">
<span class="sig-name descname"><span class="pre">content</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2983-L3002"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.content" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the GCD of polynomial coefficients.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">content</span><span class="p">()</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.count_roots">
<span class="sig-name descname"><span class="pre">count_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3484-L3545"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.count_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the number of roots of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">[inf,</span> <span class="pre">sup]</span></code> interval.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">count_roots</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">count_roots</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">I</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.decompose">
<span class="sig-name descname"><span class="pre">decompose</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3048-L3067"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.decompose" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes a functional decomposition of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;ZZ&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">decompose</span><span class="p">()</span>
<span class="go">[Poly(x**2 - x - 1, x, domain=&#39;ZZ&#39;), Poly(x**2 + x, x, domain=&#39;ZZ&#39;)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.deflate">
<span class="sig-name descname"><span class="pre">deflate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1132-L1151"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.deflate" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce degree of <code class="docutils literal notranslate"><span class="pre">f</span></code> by mapping <code class="docutils literal notranslate"><span class="pre">x_i**m</span></code> to <code class="docutils literal notranslate"><span class="pre">y_i</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">6</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">deflate</span><span class="p">()</span>
<span class="go">((3, 2), Poly(x**2*y + x + 1, x, y, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.degree">
<span class="sig-name descname"><span class="pre">degree</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">gen</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1850-L1875"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.degree" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns degree of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">x_j</span></code>.</p>
<p>The degree of 0 is negative infinity.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">degree</span><span class="p">()</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">degree</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">degree</span><span class="p">()</span>
<span class="go">-oo</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.degree_list">
<span class="sig-name descname"><span class="pre">degree_list</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1877-L1894"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.degree_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of degrees of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">degree_list</span><span class="p">()</span>
<span class="go">(2, 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.diff">
<span class="sig-name descname"><span class="pre">diff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">specs</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2357-L2393"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.diff" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes partial derivative of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">()</span>
<span class="go">Poly(2*x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">Poly(2*x*y, x, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.discriminant">
<span class="sig-name descname"><span class="pre">discriminant</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2685-L2704"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.discriminant" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the discriminant of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">discriminant</span><span class="p">()</span>
<span class="go">-8</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.dispersion">
<span class="sig-name descname"><span class="pre">dispersion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2781-L2854"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.dispersion" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the <em>dispersion</em> of polynomials.</p>
<p>For two polynomials <span class="math notranslate nohighlight">\(f(x)\)</span> and <span class="math notranslate nohighlight">\(g(x)\)</span> with <span class="math notranslate nohighlight">\(\deg f &gt; 0\)</span>
and <span class="math notranslate nohighlight">\(\deg g &gt; 0\)</span> the dispersion <span class="math notranslate nohighlight">\(\operatorname{dis}(f, g)\)</span> is defined as:</p>
<div class="math notranslate nohighlight">
\[\begin{split}\operatorname{dis}(f, g)
&amp; := \max\{ J(f,g) \cup \{0\} \} \\
&amp;  = \max\{ \{a \in \mathbb{N} | \gcd(f(x), g(x+a)) \neq 1\} \cup \{0\} \}\end{split}\]</div>
<p>and for a single polynomial <span class="math notranslate nohighlight">\(\operatorname{dis}(f) := \operatorname{dis}(f, f)\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.dispersion</span> <span class="kn">import</span> <span class="n">dispersion</span><span class="p">,</span> <span class="n">dispersionset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<p>Dispersion set and dispersion of a simple polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">((</span><span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 6]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
<p>Note that the definition of the dispersion is not symmetric:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">shift</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2, 3, 4]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">)</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">)</span>
<span class="go">-oo</span>
</pre></div>
</div>
<p>Computing the dispersion also works over field extensions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[1, 4]</span>
</pre></div>
</div>
<p>We can even perform the computations for polynomials
having symbolic coefficients:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">a</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">8</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">a</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 1]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.dispersionset" title="sympy.polys.polytools.Poly.dispersionset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dispersionset</span></code></a></p>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#manwright94" id="id5"><span>[ManWright94]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#koepf98" id="id6"><span>[Koepf98]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#abramov71" id="id7"><span>[Abramov71]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#man93" id="id8"><span>[Man93]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.dispersionset">
<span class="sig-name descname"><span class="pre">dispersionset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2706-L2779"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.dispersionset" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the <em>dispersion set</em> of two polynomials.</p>
<p>For two polynomials <span class="math notranslate nohighlight">\(f(x)\)</span> and <span class="math notranslate nohighlight">\(g(x)\)</span> with <span class="math notranslate nohighlight">\(\deg f &gt; 0\)</span>
and <span class="math notranslate nohighlight">\(\deg g &gt; 0\)</span> the dispersion set <span class="math notranslate nohighlight">\(\operatorname{J}(f, g)\)</span> is defined as:</p>
<div class="math notranslate nohighlight">
\[\begin{split}\operatorname{J}(f, g)
&amp; := \{a \in \mathbb{N}_0 | \gcd(f(x), g(x+a)) \neq 1\} \\
&amp;  = \{a \in \mathbb{N}_0 | \deg \gcd(f(x), g(x+a)) \geq 1\}\end{split}\]</div>
<p>For a single polynomial one defines <span class="math notranslate nohighlight">\(\operatorname{J}(f) := \operatorname{J}(f, f)\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.dispersion</span> <span class="kn">import</span> <span class="n">dispersion</span><span class="p">,</span> <span class="n">dispersionset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<p>Dispersion set and dispersion of a simple polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">((</span><span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 6]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
<p>Note that the definition of the dispersion is not symmetric:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">shift</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2, 3, 4]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">)</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">)</span>
<span class="go">-oo</span>
</pre></div>
</div>
<p>Computing the dispersion also works over field extensions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[1, 4]</span>
</pre></div>
</div>
<p>We can even perform the computations for polynomials
having symbolic coefficients:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">a</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">8</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">a</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 1]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.dispersion" title="sympy.polys.polytools.Poly.dispersion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dispersion</span></code></a></p>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#manwright94" id="id13"><span>[ManWright94]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#koepf98" id="id14"><span>[Koepf98]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#abramov71" id="id15"><span>[Abramov71]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#man93" id="id16"><span>[Man93]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.div">
<span class="sig-name descname"><span class="pre">div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1675-L1712"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.div" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial division with remainder of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">div</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">(Poly(1/2*x + 1, x, domain=&#39;QQ&#39;), Poly(5, x, domain=&#39;QQ&#39;))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">div</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="n">auto</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">(Poly(0, x, domain=&#39;ZZ&#39;), Poly(x**2 + 1, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.domain">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">domain</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.domain" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the ground domain of a <a class="reference internal" href="#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-class docutils literal notranslate"><span class="pre">Poly</span></code></a></p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a>:</p>
<blockquote>
<div><p>Ground domain of the <a class="reference internal" href="#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-class docutils literal notranslate"><span class="pre">Poly</span></code></a>.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">Symbol</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">Poly(x**2 + x, x, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">domain</span>
<span class="go">ZZ</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.eject">
<span class="sig-name descname"><span class="pre">eject</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1190-L1230"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.eject" title="Permalink to this definition">¶</a></dt>
<dd><p>Eject selected generators into the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">eject</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">Poly(x*y**3 + (x**2 + x)*y + 1, y, domain=&#39;ZZ[x]&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">eject</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="go">Poly(y*x**2 + (y**3 + y)*x + 1, x, domain=&#39;ZZ[y]&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.eval">
<span class="sig-name descname"><span class="pre">eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2397-L2470"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate <code class="docutils literal notranslate"><span class="pre">f</span></code> at <code class="docutils literal notranslate"><span class="pre">a</span></code> in the given variable.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">eval</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">11</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">eval</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(5*y + 8, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">z</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">eval</span><span class="p">({</span><span class="n">x</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span>
<span class="go">Poly(5*y + 2*z + 6, y, z, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">eval</span><span class="p">({</span><span class="n">x</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="mi">5</span><span class="p">})</span>
<span class="go">Poly(2*z + 31, z, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">eval</span><span class="p">({</span><span class="n">x</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span> <span class="n">z</span><span class="p">:</span> <span class="mi">7</span><span class="p">})</span>
<span class="go">45</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">eval</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Poly(2*z + 31, z, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">Poly(2*z + 31, z, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.exclude">
<span class="sig-name descname"><span class="pre">exclude</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L593-L614"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.exclude" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove unnecessary generators from <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">d</span><span class="p">,</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">a</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">d</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">exclude</span><span class="p">()</span>
<span class="go">Poly(a + x, a, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.exquo">
<span class="sig-name descname"><span class="pre">exquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1788-L1828"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.exquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial exact quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">exquo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">exquo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">2*x - 4 does not divide x**2 + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.exquo_ground">
<span class="sig-name descname"><span class="pre">exquo_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">coeff</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1340-L1364"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.exquo_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Exact quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> by a an element of the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">exquo_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">exquo_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">2 does not divide 3 in ZZ</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.factor_list">
<span class="sig-name descname"><span class="pre">factor_list</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3317-L3342"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.factor_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of irreducible factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">factor_list</span><span class="p">()</span>
<span class="go">(2, [(Poly(x + y, x, y, domain=&#39;ZZ&#39;), 1),</span>
<span class="go">     (Poly(x**2 + 1, x, y, domain=&#39;ZZ&#39;), 2)])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.factor_list_include">
<span class="sig-name descname"><span class="pre">factor_list_include</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3344-L3369"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.factor_list_include" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of irreducible factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">factor_list_include</span><span class="p">()</span>
<span class="go">[(Poly(2*x + 2*y, x, y, domain=&#39;ZZ&#39;), 1),</span>
<span class="go"> (Poly(x**2 + 1, x, y, domain=&#39;ZZ&#39;), 2)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.free_symbols">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">free_symbols</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.free_symbols" title="Permalink to this definition">¶</a></dt>
<dd><p>Free symbols of a polynomial expression.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">{x}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">{x, y}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">{x, y}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">{x, y}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.free_symbols_in_domain">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">free_symbols_in_domain</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.free_symbols_in_domain" title="Permalink to this definition">¶</a></dt>
<dd><p>Free symbols of the domain of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols_in_domain</span>
<span class="go">set()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols_in_domain</span>
<span class="go">set()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols_in_domain</span>
<span class="go">{y}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.from_dict">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L201-L205"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.from_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial from a <code class="docutils literal notranslate"><span class="pre">dict</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.from_expr">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L219-L223"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.from_expr" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial from an expression.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.from_list">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L207-L211"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.from_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial from a <code class="docutils literal notranslate"><span class="pre">list</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.from_poly">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L213-L217"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.from_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial from a polynomial.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.gcd">
<span class="sig-name descname"><span class="pre">gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2885-L2906"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the polynomial GCD of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">gcd</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x - 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.gcdex">
<span class="sig-name descname"><span class="pre">gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2525-L2556"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Extended Euclidean algorithm of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(s,</span> <span class="pre">t,</span> <span class="pre">h)</span></code> such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code> and <code class="docutils literal notranslate"><span class="pre">s*f</span> <span class="pre">+</span> <span class="pre">t*g</span> <span class="pre">=</span> <span class="pre">h</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">15</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">gcdex</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">g</span><span class="p">))</span>
<span class="go">(Poly(-1/5*x + 3/5, x, domain=&#39;QQ&#39;),</span>
<span class="go"> Poly(1/5*x**2 - 6/5*x + 2, x, domain=&#39;QQ&#39;),</span>
<span class="go"> Poly(x + 1, x, domain=&#39;QQ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.gen">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">gen</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.gen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the principal generator.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">gen</span>
<span class="go">x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.get_domain">
<span class="sig-name descname"><span class="pre">get_domain</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L538-L540"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.get_domain" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the ground domain of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.get_modulus">
<span class="sig-name descname"><span class="pre">get_modulus</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L559-L578"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.get_modulus" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the modulus of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">modulus</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">get_modulus</span><span class="p">()</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.gff_list">
<span class="sig-name descname"><span class="pre">gff_list</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3145-L3166"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.gff_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes greatest factorial factorization of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">gff_list</span><span class="p">()</span>
<span class="go">[(Poly(x, x, domain=&#39;ZZ&#39;), 1), (Poly(x + 2, x, domain=&#39;ZZ&#39;), 4)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.ground_roots">
<span class="sig-name descname"><span class="pre">ground_roots</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3698-L3723"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.ground_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute roots of <code class="docutils literal notranslate"><span class="pre">f</span></code> by factorization in the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">ground_roots</span><span class="p">()</span>
<span class="go">{0: 2, 1: 2}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.half_gcdex">
<span class="sig-name descname"><span class="pre">half_gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2494-L2523"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.half_gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Half extended Euclidean algorithm of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(s,</span> <span class="pre">h)</span></code> such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code> and <code class="docutils literal notranslate"><span class="pre">s*f</span> <span class="pre">=</span> <span class="pre">h</span> <span class="pre">(mod</span> <span class="pre">g)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">15</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">half_gcdex</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">g</span><span class="p">))</span>
<span class="go">(Poly(-1/5*x + 3/5, x, domain=&#39;QQ&#39;), Poly(x + 1, x, domain=&#39;QQ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.has_only_gens">
<span class="sig-name descname"><span class="pre">has_only_gens</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L717-L749"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.has_only_gens" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">Poly(f,</span> <span class="pre">*gens)</span></code> retains ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">has_only_gens</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">z</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">has_only_gens</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.homogeneous_order">
<span class="sig-name descname"><span class="pre">homogeneous_order</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1951-L1974"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.homogeneous_order" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the homogeneous order of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>A homogeneous polynomial is a polynomial whose all monomials with
non-zero coefficients have the same total degree. This degree is
the homogeneous order of <code class="docutils literal notranslate"><span class="pre">f</span></code>. If you only want to check if a
polynomial is homogeneous, then use <a class="reference internal" href="#sympy.polys.polytools.Poly.is_homogeneous" title="sympy.polys.polytools.Poly.is_homogeneous"><code class="xref py py-func docutils literal notranslate"><span class="pre">Poly.is_homogeneous()</span></code></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">9</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">homogeneous_order</span><span class="p">()</span>
<span class="go">5</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.homogenize">
<span class="sig-name descname"><span class="pre">homogenize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1917-L1949"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.homogenize" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the homogeneous polynomial of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>A homogeneous polynomial is a polynomial whose all monomials with
non-zero coefficients have the same total degree. If you only
want to check if a polynomial is homogeneous, then use
<a class="reference internal" href="#sympy.polys.polytools.Poly.is_homogeneous" title="sympy.polys.polytools.Poly.is_homogeneous"><code class="xref py py-func docutils literal notranslate"><span class="pre">Poly.is_homogeneous()</span></code></a>. If you want not only to check if a
polynomial is homogeneous but also compute its homogeneous order,
then use <a class="reference internal" href="#sympy.polys.polytools.Poly.homogeneous_order" title="sympy.polys.polytools.Poly.homogeneous_order"><code class="xref py py-func docutils literal notranslate"><span class="pre">Poly.homogeneous_order()</span></code></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">9</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">homogenize</span><span class="p">(</span><span class="n">z</span><span class="p">)</span>
<span class="go">Poly(x**5 + 2*x**2*y**2*z + 9*x*y**3*z, x, y, z, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.inject">
<span class="sig-name descname"><span class="pre">inject</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">front</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1153-L1188"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.inject" title="Permalink to this definition">¶</a></dt>
<dd><p>Inject ground domain generators into <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">inject</span><span class="p">()</span>
<span class="go">Poly(x**2*y + x*y**3 + x*y + 1, x, y, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">inject</span><span class="p">(</span><span class="n">front</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">Poly(y**3*x + y*x**2 + y*x + 1, y, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.integrate">
<span class="sig-name descname"><span class="pre">integrate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">specs</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2317-L2355"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.integrate" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes indefinite integral of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">integrate</span><span class="p">()</span>
<span class="go">Poly(1/3*x**3 + x**2 + x, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">integrate</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">Poly(1/2*x**2*y**2 + 1/2*x**2, x, y, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.intervals">
<span class="sig-name descname"><span class="pre">intervals</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fast</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sqf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3371-L3445"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.intervals" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute isolating intervals for roots of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>For real roots the Vincent-Akritas-Strzebonski (VAS) continued fractions method is used.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">intervals</span><span class="p">()</span>
<span class="go">[((-2, -1), 1), ((1, 2), 1)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">intervals</span><span class="p">(</span><span class="n">eps</span><span class="o">=</span><span class="mf">1e-2</span><span class="p">)</span>
<span class="go">[((-26/15, -19/11), 1), ((19/11, 26/15), 1)]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="footnote brackets">
<dt class="label" id="id21"><span class="brackets">1</span></dt>
<dd><p>Alkiviadis G. Akritas and Adam W. Strzebonski: A Comparative Study of Two Real Root
Isolation Methods . Nonlinear Analysis: Modelling and Control, Vol. 10, No. 4, 297-304, 2005.</p>
</dd>
<dt class="label" id="id22"><span class="brackets">2</span></dt>
<dd><p>Alkiviadis G. Akritas, Adam W. Strzebonski and Panagiotis S. Vigklas: Improving the
Performance of the Continued Fractions Method Using new Bounds of Positive Roots. Nonlinear
Analysis: Modelling and Control, Vol. 13, No. 3, 265-279, 2008.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.invert">
<span class="sig-name descname"><span class="pre">invert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2558-L2587"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.invert" title="Permalink to this definition">¶</a></dt>
<dd><p>Invert <code class="docutils literal notranslate"><span class="pre">f</span></code> modulo <code class="docutils literal notranslate"><span class="pre">g</span></code> when possible.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">invert</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(-4/3, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">invert</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">NotInvertible</span>: <span class="n">zero divisor</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_cyclotomic">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_cyclotomic</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_cyclotomic" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a cyclotomic polnomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">16</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">14</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">10</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">8</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">is_cyclotomic</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">16</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">14</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">8</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">g</span><span class="p">)</span><span class="o">.</span><span class="n">is_cyclotomic</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_ground">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_ground</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is an element of the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_ground</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_ground</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_ground</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_homogeneous">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_homogeneous</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_homogeneous" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a homogeneous polynomial.</p>
<p>A homogeneous polynomial is a polynomial whose all monomials with
non-zero coefficients have the same total degree. If you want not
only to check if a polynomial is homogeneous but also compute its
homogeneous order, then use <a class="reference internal" href="#sympy.polys.polytools.Poly.homogeneous_order" title="sympy.polys.polytools.Poly.homogeneous_order"><code class="xref py py-func docutils literal notranslate"><span class="pre">Poly.homogeneous_order()</span></code></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_homogeneous</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_homogeneous</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_irreducible">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_irreducible</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_irreducible" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> has no factors over its domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">modulus</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">is_irreducible</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">modulus</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">is_irreducible</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_linear">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_linear</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_linear" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is linear in all its variables.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_linear</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_linear</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_monic">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_monic</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_monic" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the leading coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code> is one.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_monic</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_monic</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_monomial">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_monomial</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_monomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is zero or has only one term.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_monomial</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_monomial</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_multivariate">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_multivariate</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_multivariate" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a multivariate polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_multivariate</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_multivariate</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_multivariate</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_multivariate</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_one">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_one</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_one" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a unit polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_one</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_one</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_primitive">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_primitive</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_primitive" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if GCD of the coefficients of <code class="docutils literal notranslate"><span class="pre">f</span></code> is one.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_primitive</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">6</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_primitive</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_quadratic">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_quadratic</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_quadratic" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is quadratic in all its variables.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_quadratic</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_quadratic</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_sqf">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_sqf</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_sqf" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a square-free polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_sqf</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_sqf</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_univariate">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_univariate</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_univariate" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a univariate polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_univariate</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_univariate</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_univariate</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">is_univariate</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.is_zero">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_zero</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.is_zero" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a zero polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_zero</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">is_zero</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.l1_norm">
<span class="sig-name descname"><span class="pre">l1_norm</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2218-L2237"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.l1_norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns l1 norm of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">l1_norm</span><span class="p">()</span>
<span class="go">6</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.lcm">
<span class="sig-name descname"><span class="pre">lcm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2908-L2929"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.lcm" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns polynomial LCM of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">lcm</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x**3 - 2*x**2 - x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.length">
<span class="sig-name descname"><span class="pre">length</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1005-L1019"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.length" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of non-zero terms in <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">length</span><span class="p">()</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.lift">
<span class="sig-name descname"><span class="pre">lift</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1111-L1130"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.lift" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert algebraic coefficients to rationals.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="n">I</span><span class="p">)</span><span class="o">.</span><span class="n">lift</span><span class="p">()</span>
<span class="go">Poly(x**4 + 3*x**2 + 1, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.ltrim">
<span class="sig-name descname"><span class="pre">ltrim</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">gen</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L681-L715"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.ltrim" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove dummy generators from <code class="docutils literal notranslate"><span class="pre">f</span></code> that are to the left of
specified <code class="docutils literal notranslate"><span class="pre">gen</span></code> in the generators as ordered. When <code class="docutils literal notranslate"><span class="pre">gen</span></code>
is an integer, it refers to the generator located at that
position within the tuple of generators of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">z</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="go">Poly(y**2 + y*z**2, y, z, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">ltrim</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="go">Poly(z, z, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.match">
<span class="sig-name descname"><span class="pre">match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L651-L653"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.match" title="Permalink to this definition">¶</a></dt>
<dd><p>Match expression from Poly. See Basic.match()</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.max_norm">
<span class="sig-name descname"><span class="pre">max_norm</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2197-L2216"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.max_norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns maximum norm of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">max_norm</span><span class="p">()</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.monic">
<span class="sig-name descname"><span class="pre">monic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2954-L2981"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.monic" title="Permalink to this definition">¶</a></dt>
<dd><p>Divides all coefficients by <code class="docutils literal notranslate"><span class="pre">LC(f)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">9</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">ZZ</span><span class="p">)</span><span class="o">.</span><span class="n">monic</span><span class="p">()</span>
<span class="go">Poly(x**2 + 2*x + 3, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">ZZ</span><span class="p">)</span><span class="o">.</span><span class="n">monic</span><span class="p">()</span>
<span class="go">Poly(x**2 + 4/3*x + 2/3, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.monoms">
<span class="sig-name descname"><span class="pre">monoms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L876-L894"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.monoms" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all non-zero monomials from <code class="docutils literal notranslate"><span class="pre">f</span></code> in lex order.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">monoms</span><span class="p">()</span>
<span class="go">[(2, 0), (1, 2), (1, 1), (0, 1)]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.all_monoms" title="sympy.polys.polytools.Poly.all_monoms"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_monoms</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.mul">
<span class="sig-name descname"><span class="pre">mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1473-L1502"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply two polynomials <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">mul</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x**3 - 2*x**2 + x - 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Poly(x**3 - 2*x**2 + x - 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.mul_ground">
<span class="sig-name descname"><span class="pre">mul_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">coeff</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1295-L1314"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.mul_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply <code class="docutils literal notranslate"><span class="pre">f</span></code> by a an element of the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">mul_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(2*x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.neg">
<span class="sig-name descname"><span class="pre">neg</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1387-L1409"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.neg" title="Permalink to this definition">¶</a></dt>
<dd><p>Negate all coefficients in <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">neg</span><span class="p">()</span>
<span class="go">Poly(-x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="o">-</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Poly(-x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.new">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">new</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L175-L188"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.new" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct <a class="reference internal" href="#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-class docutils literal notranslate"><span class="pre">Poly</span></code></a> instance from raw representation.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.norm">
<span class="sig-name descname"><span class="pre">norm</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3168-L3201"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the product, <code class="docutils literal notranslate"><span class="pre">Norm(f)</span></code>, of the conjugates of
a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> defined over a number field <code class="docutils literal notranslate"><span class="pre">K</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">=</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>A polynomial over a quadratic extension.
Two conjugates x - a and x + a.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">a</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="n">a</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">norm</span><span class="p">()</span>
<span class="go">Poly(x**2 - 2, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
<p>A polynomial over a quartic extension.
Four conjugates x - a, x - a, x + a and x + a.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">a</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">norm</span><span class="p">()</span>
<span class="go">Poly(x**4 - 4*x**2 + 4, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.nroots">
<span class="sig-name descname"><span class="pre">nroots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxsteps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">50</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cleanup</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3624-L3696"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.nroots" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute numerical approximations of roots of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n … the number of digits to calculate</strong></p>
<p><strong>maxsteps … the maximum number of iterations to do</strong></p>
<p><strong>If the accuracy `n` cannot be reached in `maxsteps`, it will raise an</strong></p>
<p><strong>exception. You need to rerun with higher maxsteps.</strong></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">nroots</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
<span class="go">[-1.73205080756888, 1.73205080756888]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">nroots</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
<span class="go">[-1.73205080756887729352744634151, 1.73205080756887729352744634151]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.nth">
<span class="sig-name descname"><span class="pre">nth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">N</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2077-L2109"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.nth" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the <code class="docutils literal notranslate"><span class="pre">n</span></code>-th coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code> where <code class="docutils literal notranslate"><span class="pre">N</span></code> are the
exponents of the generators in the term of interest.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">nth</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">nth</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="go">Poly(4*y*(sqrt(x)), y, sqrt(x), domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">_</span><span class="o">.</span><span class="n">nth</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">4</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.coeff_monomial" title="sympy.polys.polytools.Poly.coeff_monomial"><code class="xref py py-obj docutils literal notranslate"><span class="pre">coeff_monomial</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.nth_power_roots_poly">
<span class="sig-name descname"><span class="pre">nth_power_roots_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3725-L3763"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.nth_power_roots_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a polynomial with n-th powers of roots of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">nth_power_roots_poly</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x**4 - 2*x**3 + 3*x**2 - 2*x + 1, x, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">nth_power_roots_poly</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="go">Poly(x**4 + 2*x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">nth_power_roots_poly</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
<span class="go">Poly(x**4 + 2*x**3 + 3*x**2 + 2*x + 1, x, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">nth_power_roots_poly</span><span class="p">(</span><span class="mi">12</span><span class="p">)</span>
<span class="go">Poly(x**4 - 4*x**3 + 6*x**2 - 4*x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.one">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">one</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.one" title="Permalink to this definition">¶</a></dt>
<dd><p>Return one polynomial with <code class="docutils literal notranslate"><span class="pre">self</span></code>’s properties.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.pdiv">
<span class="sig-name descname"><span class="pre">pdiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1554-L1575"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.pdiv" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial pseudo-division of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">pdiv</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">(Poly(2*x + 4, x, domain=&#39;ZZ&#39;), Poly(20, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.per">
<span class="sig-name descname"><span class="pre">per</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gens</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">remove</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L504-L531"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.per" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Poly out of the given representation.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyclasses</span> <span class="kn">import</span> <span class="n">DMP</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">per</span><span class="p">(</span><span class="n">DMP</span><span class="p">([</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="n">ZZ</span><span class="p">),</span> <span class="n">gens</span><span class="o">=</span><span class="p">[</span><span class="n">y</span><span class="p">])</span>
<span class="go">Poly(y + 1, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.pexquo">
<span class="sig-name descname"><span class="pre">pexquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1644-L1673"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.pexquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial exact pseudo-quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">pexquo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(2*x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">pexquo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">2*x - 4 does not divide x**2 + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.pow">
<span class="sig-name descname"><span class="pre">pow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1528-L1552"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.pow" title="Permalink to this definition">¶</a></dt>
<dd><p>Raise <code class="docutils literal notranslate"><span class="pre">f</span></code> to a non-negative power <code class="docutils literal notranslate"><span class="pre">n</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">pow</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="go">Poly(x**3 - 6*x**2 + 12*x - 8, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="mi">3</span>
<span class="go">Poly(x**3 - 6*x**2 + 12*x - 8, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.pquo">
<span class="sig-name descname"><span class="pre">pquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1616-L1642"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.pquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial pseudo-quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>See the Caveat note in the function prem(f, g).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">pquo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(2*x + 4, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">pquo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(2*x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.prem">
<span class="sig-name descname"><span class="pre">prem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1577-L1614"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.prem" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial pseudo-remainder of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<dl>
<dt>Caveat: The function prem(f, g, x) can be safely used to compute</dt><dd><p>in Z[x] _only_ subresultant polynomial remainder sequences (prs’s).</p>
<p>To safely compute Euclidean and Sturmian prs’s in Z[x]
employ anyone of the corresponding functions found in
the module sympy.polys.subresultants_qq_zz. The functions
in the module with suffix _pg compute prs’s in Z[x] employing
rem(f, g, x), whereas the functions with suffix _amv
compute prs’s in Z[x] employing rem_z(f, g, x).</p>
<p>The function rem_z(f, g, x) differs from prem(f, g, x) in that
to compute the remainder polynomials in Z[x] it premultiplies
the divident times the absolute value of the leading coefficient
of the divisor raised to the power degree(f, x) - degree(g, x) + 1.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">prem</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(20, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.primitive">
<span class="sig-name descname"><span class="pre">primitive</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3004-L3023"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.primitive" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the content and a primitive form of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">primitive</span><span class="p">()</span>
<span class="go">(2, Poly(x**2 + 4*x + 6, x, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.quo">
<span class="sig-name descname"><span class="pre">quo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1751-L1786"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.quo" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">quo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(1/2*x + 1, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">quo</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.quo_ground">
<span class="sig-name descname"><span class="pre">quo_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">coeff</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1316-L1338"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.quo_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Quotient of <code class="docutils literal notranslate"><span class="pre">f</span></code> by a an element of the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">quo_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x + 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">quo_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.rat_clear_denoms">
<span class="sig-name descname"><span class="pre">rat_clear_denoms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2278-L2315"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.rat_clear_denoms" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear denominators in a rational function <code class="docutils literal notranslate"><span class="pre">f/g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">,</span> <span class="n">q</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">rat_clear_denoms</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">Poly(x**2 + y, x, domain=&#39;ZZ[y]&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q</span>
<span class="go">Poly(y*x**3 + y**2, x, domain=&#39;ZZ[y]&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.real_roots">
<span class="sig-name descname"><span class="pre">real_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">multiple</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3576-L3597"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.real_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of real roots with multiplicities.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">real_roots</span><span class="p">()</span>
<span class="go">[-1/2, 2, 2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">real_roots</span><span class="p">()</span>
<span class="go">[CRootOf(x**3 + x + 1, 0)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.refine_root">
<span class="sig-name descname"><span class="pre">refine_root</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">t</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fast</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">check_sqf</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3447-L3482"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.refine_root" title="Permalink to this definition">¶</a></dt>
<dd><p>Refine an isolating interval of a root to the given precision.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">refine_root</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="mf">1e-2</span><span class="p">)</span>
<span class="go">(19/11, 26/15)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.rem">
<span class="sig-name descname"><span class="pre">rem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1714-L1749"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.rem" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the polynomial remainder of <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">rem</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(5, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">rem</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="n">auto</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.reorder">
<span class="sig-name descname"><span class="pre">reorder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L655-L679"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.reorder" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently apply new order of generators.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">reorder</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Poly(y**2*x + x**2, y, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.replace">
<span class="sig-name descname"><span class="pre">replace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">_ignore</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L616-L649"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.replace" title="Permalink to this definition">¶</a></dt>
<dd><p>Replace <code class="docutils literal notranslate"><span class="pre">x</span></code> with <code class="docutils literal notranslate"><span class="pre">y</span></code> in generators list.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">Poly(y**2 + 1, y, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.resultant">
<span class="sig-name descname"><span class="pre">resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">includePRS</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2648-L2683"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the resultant of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> via PRS.</p>
<p>If includePRS=True, it includes the subresultant PRS in the result.
Because the PRS is used to calculate the resultant, this is more
efficient than calling <a class="reference internal" href="#sympy.polys.polytools.subresultants" title="sympy.polys.polytools.subresultants"><code class="xref py py-func docutils literal notranslate"><span class="pre">subresultants()</span></code></a> separately.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">resultant</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">resultant</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="n">includePRS</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(4, [Poly(x**2 + 1, x, domain=&#39;ZZ&#39;), Poly(x**2 - 1, x, domain=&#39;ZZ&#39;),</span>
<span class="go">     Poly(-2, x, domain=&#39;ZZ&#39;)])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.retract">
<span class="sig-name descname"><span class="pre">retract</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">field</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L814-L836"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.retract" title="Permalink to this definition">¶</a></dt>
<dd><p>Recalculate the ground domain of a polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ[y]&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;QQ[y]&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">retract</span><span class="p">()</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">retract</span><span class="p">(</span><span class="n">field</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.revert">
<span class="sig-name descname"><span class="pre">revert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2589-L2621"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.revert" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f**(-1)</span></code> mod <code class="docutils literal notranslate"><span class="pre">x**n</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">revert</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">revert</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">Poly(1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">revert</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">NotReversible</span>: <span class="n">only units are reversible in a ring</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">revert</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">PolynomialError</span>: <span class="n">1/x contains an element of the generators set</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.root">
<span class="sig-name descname"><span class="pre">root</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3547-L3574"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.root" title="Permalink to this definition">¶</a></dt>
<dd><p>Get an indexed root of a polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">root</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="go">-1/2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">root</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">root</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="o">.</span><span class="n">root</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">IndexError</span>: <span class="n">root index out of [-3, 2] range, got 3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">root</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="go">CRootOf(x**3 - x**2 + 1, 0)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.set_domain">
<span class="sig-name descname"><span class="pre">set_domain</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L533-L536"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.set_domain" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the ground domain of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.set_modulus">
<span class="sig-name descname"><span class="pre">set_modulus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">modulus</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L542-L557"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.set_modulus" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the modulus of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">5</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">set_modulus</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x**2 + 1, x, modulus=2)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.shift">
<span class="sig-name descname"><span class="pre">shift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3069-L3088"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.shift" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently compute Taylor shift <code class="docutils literal notranslate"><span class="pre">f(x</span> <span class="pre">+</span> <span class="pre">a)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">shift</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x**2 + 2*x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.slice">
<span class="sig-name descname"><span class="pre">slice</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L838-L852"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.slice" title="Permalink to this definition">¶</a></dt>
<dd><p>Take a continuous subsequence of terms of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sqf_list">
<span class="sig-name descname"><span class="pre">sqf_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3255-L3282"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sqf_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of square-free factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">16</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">50</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">76</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">56</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">16</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">sqf_list</span><span class="p">()</span>
<span class="go">(2, [(Poly(x + 1, x, domain=&#39;ZZ&#39;), 2),</span>
<span class="go">     (Poly(x + 2, x, domain=&#39;ZZ&#39;), 3)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">sqf_list</span><span class="p">(</span><span class="nb">all</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(2, [(Poly(1, x, domain=&#39;ZZ&#39;), 1),</span>
<span class="go">     (Poly(x + 1, x, domain=&#39;ZZ&#39;), 2),</span>
<span class="go">     (Poly(x + 2, x, domain=&#39;ZZ&#39;), 3)])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sqf_list_include">
<span class="sig-name descname"><span class="pre">sqf_list_include</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3284-L3315"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sqf_list_include" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of square-free factors of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">expand</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">expand</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span>
<span class="go">2*x**7 + 6*x**6 + 6*x**5 + 2*x**4</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">sqf_list_include</span><span class="p">()</span>
<span class="go">[(Poly(2, x, domain=&#39;ZZ&#39;), 1),</span>
<span class="go"> (Poly(x + 1, x, domain=&#39;ZZ&#39;), 3),</span>
<span class="go"> (Poly(x, x, domain=&#39;ZZ&#39;), 4)]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">sqf_list_include</span><span class="p">(</span><span class="nb">all</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">[(Poly(2, x, domain=&#39;ZZ&#39;), 1),</span>
<span class="go"> (Poly(1, x, domain=&#39;ZZ&#39;), 2),</span>
<span class="go"> (Poly(x + 1, x, domain=&#39;ZZ&#39;), 3),</span>
<span class="go"> (Poly(x, x, domain=&#39;ZZ&#39;), 4)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sqf_norm">
<span class="sig-name descname"><span class="pre">sqf_norm</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3203-L3232"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sqf_norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes square-free norm of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">s</span></code>, <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">r</span></code>, such that <code class="docutils literal notranslate"><span class="pre">g(x)</span> <span class="pre">=</span> <span class="pre">f(x-sa)</span></code> and
<code class="docutils literal notranslate"><span class="pre">r(x)</span> <span class="pre">=</span> <span class="pre">Norm(g(x))</span></code> is a square-free polynomial over <code class="docutils literal notranslate"><span class="pre">K</span></code>,
where <code class="docutils literal notranslate"><span class="pre">a</span></code> is the algebraic extension of the ground domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">extension</span><span class="o">=</span><span class="p">[</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">)])</span><span class="o">.</span><span class="n">sqf_norm</span><span class="p">()</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span>
<span class="go">Poly(x**2 - 2*sqrt(3)*x + 4, x, domain=&#39;QQ&lt;sqrt(3)&gt;&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span>
<span class="go">Poly(x**4 - 4*x**2 + 16, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sqf_part">
<span class="sig-name descname"><span class="pre">sqf_part</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3234-L3253"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sqf_part" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes square-free part of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">sqf_part</span><span class="p">()</span>
<span class="go">Poly(x**2 - x - 2, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sqr">
<span class="sig-name descname"><span class="pre">sqr</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1504-L1526"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sqr" title="Permalink to this definition">¶</a></dt>
<dd><p>Square a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">sqr</span><span class="p">()</span>
<span class="go">Poly(x**2 - 4*x + 4, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span>
<span class="go">Poly(x**2 - 4*x + 4, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sturm">
<span class="sig-name descname"><span class="pre">sturm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3116-L3143"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sturm" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the Sturm sequence of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">sturm</span><span class="p">()</span>
<span class="go">[Poly(x**3 - 2*x**2 + x - 3, x, domain=&#39;QQ&#39;),</span>
<span class="go"> Poly(3*x**2 - 4*x + 1, x, domain=&#39;QQ&#39;),</span>
<span class="go"> Poly(2/9*x + 25/9, x, domain=&#39;QQ&#39;),</span>
<span class="go"> Poly(-2079/4, x, domain=&#39;QQ&#39;)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sub">
<span class="sig-name descname"><span class="pre">sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1442-L1471"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sub" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtract two polynomials <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(x**2 - x + 3, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Poly(x**2 - x + 3, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.sub_ground">
<span class="sig-name descname"><span class="pre">sub_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">coeff</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1274-L1293"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.sub_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtract an element of the ground domain from <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">sub_ground</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">Poly(x - 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.subresultants">
<span class="sig-name descname"><span class="pre">subresultants</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2623-L2646"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.subresultants" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the subresultant PRS of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">subresultants</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">[Poly(x**2 + 1, x, domain=&#39;ZZ&#39;),</span>
<span class="go"> Poly(x**2 - 1, x, domain=&#39;ZZ&#39;),</span>
<span class="go"> Poly(-2, x, domain=&#39;ZZ&#39;)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.terms">
<span class="sig-name descname"><span class="pre">terms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L896-L914"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.terms" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all non-zero terms from <code class="docutils literal notranslate"><span class="pre">f</span></code> in lex order.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">terms</span><span class="p">()</span>
<span class="go">[((2, 0), 1), ((1, 2), 2), ((1, 1), 1), ((0, 1), 3)]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.polytools.Poly.all_terms" title="sympy.polys.polytools.Poly.all_terms"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_terms</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.terms_gcd">
<span class="sig-name descname"><span class="pre">terms_gcd</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1232-L1251"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.terms_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove GCD of terms from the polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">6</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">terms_gcd</span><span class="p">()</span>
<span class="go">((3, 1), Poly(x**3*y + 1, x, y, domain=&#39;ZZ&#39;))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.termwise">
<span class="sig-name descname"><span class="pre">termwise</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L968-L1003"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.termwise" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a function to all terms of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">coeff</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">k</span> <span class="o">=</span> <span class="n">k</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="n">coeff</span><span class="o">//</span><span class="mi">10</span><span class="o">**</span><span class="p">(</span><span class="mi">2</span><span class="o">-</span><span class="n">k</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">20</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">400</span><span class="p">)</span><span class="o">.</span><span class="n">termwise</span><span class="p">(</span><span class="n">func</span><span class="p">)</span>
<span class="go">Poly(x**2 + 2*x + 4, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.to_exact">
<span class="sig-name descname"><span class="pre">to_exact</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L793-L812"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.to_exact" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the ground domain exact.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">RR</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">RR</span><span class="p">)</span><span class="o">.</span><span class="n">to_exact</span><span class="p">()</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.to_field">
<span class="sig-name descname"><span class="pre">to_field</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L772-L791"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.to_field" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the ground domain a field.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">ZZ</span><span class="p">)</span><span class="o">.</span><span class="n">to_field</span><span class="p">()</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.to_ring">
<span class="sig-name descname"><span class="pre">to_ring</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L751-L770"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.to_ring" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the ground domain a ring.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">QQ</span><span class="p">)</span><span class="o">.</span><span class="n">to_ring</span><span class="p">()</span>
<span class="go">Poly(x**2 + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.total_degree">
<span class="sig-name descname"><span class="pre">total_degree</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L1896-L1915"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.total_degree" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the total degree of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">total_degree</span><span class="p">()</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">5</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">total_degree</span><span class="p">()</span>
<span class="go">5</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.transform">
<span class="sig-name descname"><span class="pre">transform</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">q</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L3090-L3114"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently evaluate the functional transformation <code class="docutils literal notranslate"><span class="pre">q**n</span> <span class="pre">*</span> <span class="pre">f(p/q)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">Poly(4, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.trunc">
<span class="sig-name descname"><span class="pre">trunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L2931-L2952"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.trunc" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce <code class="docutils literal notranslate"><span class="pre">f</span></code> modulo a constant <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">7</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">trunc</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="go">Poly(-x**3 - x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.unify">
<span class="sig-name descname"><span class="pre">unify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L425-L451"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.Poly.unify" title="Permalink to this definition">¶</a></dt>
<dd><p>Make <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> belong to the same domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">,</span> <span class="n">g</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">Poly</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span>
<span class="go">Poly(1/2*x + 1, x, domain=&#39;QQ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span>
<span class="go">Poly(2*x + 1, x, domain=&#39;ZZ&#39;)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">F</span><span class="p">,</span> <span class="n">G</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">unify</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">F</span>
<span class="go">Poly(1/2*x + 1, x, domain=&#39;QQ&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span>
<span class="go">Poly(2*x + 1, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.unit">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">unit</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.unit" title="Permalink to this definition">¶</a></dt>
<dd><p>Return unit polynomial with <code class="docutils literal notranslate"><span class="pre">self</span></code>’s properties.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.Poly.zero">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">zero</span></span><a class="headerlink" href="#sympy.polys.polytools.Poly.zero" title="Permalink to this definition">¶</a></dt>
<dd><p>Return zero polynomial with <code class="docutils literal notranslate"><span class="pre">self</span></code>’s properties.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polytools.PurePoly">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">PurePoly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L4195-L4286"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.PurePoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Class for representing pure polynomials.</p>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.PurePoly.free_symbols">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">free_symbols</span></span><a class="headerlink" href="#sympy.polys.polytools.PurePoly.free_symbols" title="Permalink to this definition">¶</a></dt>
<dd><p>Free symbols of a polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">PurePoly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePoly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">set()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePoly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">set()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePoly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">free_symbols</span>
<span class="go">{y}</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polytools.GroebnerBasis">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polytools.</span></span><span class="sig-name descname"><span class="pre">GroebnerBasis</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6877-L7147"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.GroebnerBasis" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a reduced Groebner basis.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.GroebnerBasis.contains">
<span class="sig-name descname"><span class="pre">contains</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L7128-L7147"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.GroebnerBasis.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if <code class="docutils literal notranslate"><span class="pre">poly</span></code> belongs the ideal generated by <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">groebner</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span> <span class="o">=</span> <span class="n">groebner</span><span class="p">([</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="mi">2</span><span class="p">])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">f</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.GroebnerBasis.fglm">
<span class="sig-name descname"><span class="pre">fglm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L6997-L7061"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.GroebnerBasis.fglm" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a Groebner basis from one ordering to another.</p>
<p>The FGLM algorithm converts reduced Groebner bases of zero-dimensional
ideals from one ordering to another. This method is often used when it
is infeasible to compute a Groebner basis with respect to a particular
ordering directly.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">groebner</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">F</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span> <span class="o">=</span> <span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;grlex&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">G</span><span class="o">.</span><span class="n">fglm</span><span class="p">(</span><span class="s1">&#39;lex&#39;</span><span class="p">))</span>
<span class="go">[2*x - y**2 - y + 1, y**4 + 2*y**3 - 3*y**2 - 16*y + 7]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">groebner</span><span class="p">(</span><span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;lex&#39;</span><span class="p">))</span>
<span class="go">[2*x - y**2 - y + 1, y**4 + 2*y**3 - 3*y**2 - 16*y + 7]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r663"><span class="brackets"><a class="fn-backref" href="#id23">R663</a></span></dt>
<dd><p>J.C. Faugere, P. Gianni, D. Lazard, T. Mora (1994). Efficient
Computation of Zero-dimensional Groebner Bases by Change of
Ordering</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.polytools.GroebnerBasis.is_zero_dimensional">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_zero_dimensional</span></span><a class="headerlink" href="#sympy.polys.polytools.GroebnerBasis.is_zero_dimensional" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if the ideal generated by a Groebner basis is zero-dimensional.</p>
<p>The algorithm checks if the set of monomials not divisible by the
leading monomial of any element of <code class="docutils literal notranslate"><span class="pre">F</span></code> is bounded.</p>
<p class="rubric">References</p>
<p>David A. Cox, John B. Little, Donal O’Shea. Ideals, Varieties and
Algorithms, 3rd edition, p. 230</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polytools.GroebnerBasis.reduce">
<span class="sig-name descname"><span class="pre">reduce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polytools.py#L7063-L7126"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polytools.GroebnerBasis.reduce" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduces a polynomial modulo a Groebner basis.</p>
<p>Given a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> and a set of polynomials <code class="docutils literal notranslate"><span class="pre">G</span> <span class="pre">=</span> <span class="pre">(g_1,</span> <span class="pre">...,</span> <span class="pre">g_n)</span></code>,
computes a set of quotients <code class="docutils literal notranslate"><span class="pre">q</span> <span class="pre">=</span> <span class="pre">(q_1,</span> <span class="pre">...,</span> <span class="pre">q_n)</span></code> and the remainder <code class="docutils literal notranslate"><span class="pre">r</span></code>
such that <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">q_1*f_1</span> <span class="pre">+</span> <span class="pre">...</span> <span class="pre">+</span> <span class="pre">q_n*f_n</span> <span class="pre">+</span> <span class="pre">r</span></code>, where <code class="docutils literal notranslate"><span class="pre">r</span></code> vanishes or <code class="docutils literal notranslate"><span class="pre">r</span></code>
is a completely reduced polynomial with respect to <code class="docutils literal notranslate"><span class="pre">G</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">groebner</span><span class="p">,</span> <span class="n">expand</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span> <span class="o">=</span> <span class="n">groebner</span><span class="p">([</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="n">y</span><span class="p">])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">G</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">([2*x, 1], x**2 + y**2 + y)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">_</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">expand</span><span class="p">(</span><span class="nb">sum</span><span class="p">(</span><span class="n">q</span><span class="o">*</span><span class="n">g</span> <span class="k">for</span> <span class="n">q</span><span class="p">,</span> <span class="n">g</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">Q</span><span class="p">,</span> <span class="n">G</span><span class="p">))</span> <span class="o">+</span> <span class="n">r</span><span class="p">)</span>
<span class="go">2*x**4 - x**2 + y**3 + y**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">_</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
<section id="extra-polynomial-manipulation-functions">
<h2>Extra polynomial manipulation functions<a class="headerlink" href="#extra-polynomial-manipulation-functions" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyfuncs.symmetrize">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyfuncs.</span></span><span class="sig-name descname"><span class="pre">symmetrize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyfuncs.py#L15-L145"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyfuncs.symmetrize" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a polynomial in terms of elementary symmetric polynomials.</p>
<p>A symmetric polynomial is a multivariate polynomial that remains invariant
under any variable permutation, i.e., if <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">f(x_1,</span> <span class="pre">x_2,</span> <span class="pre">...,</span> <span class="pre">x_n)</span></code>,
then <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">f(x_{i_1},</span> <span class="pre">x_{i_2},</span> <span class="pre">...,</span> <span class="pre">x_{i_n})</span></code>, where
<code class="docutils literal notranslate"><span class="pre">(i_1,</span> <span class="pre">i_2,</span> <span class="pre">...,</span> <span class="pre">i_n)</span></code> is a permutation of <code class="docutils literal notranslate"><span class="pre">(1,</span> <span class="pre">2,</span> <span class="pre">...,</span> <span class="pre">n)</span></code> (an
element of the group <code class="docutils literal notranslate"><span class="pre">S_n</span></code>).</p>
<p>Returns a tuple of symmetric polynomials <code class="docutils literal notranslate"><span class="pre">(f1,</span> <span class="pre">f2,</span> <span class="pre">...,</span> <span class="pre">fn)</span></code> such that
<code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">f1</span> <span class="pre">+</span> <span class="pre">f2</span> <span class="pre">+</span> <span class="pre">...</span> <span class="pre">+</span> <span class="pre">fn</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyfuncs</span> <span class="kn">import</span> <span class="n">symmetrize</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">symmetrize</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">(-2*x*y + (x + y)**2, 0)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">symmetrize</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">formal</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(s1**2 - 2*s2, 0, [(s1, x + y), (s2, x*y)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">symmetrize</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">(-2*x*y + (x + y)**2, -2*y**2)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">symmetrize</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">formal</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(s1**2 - 2*s2, -2*y**2, [(s1, x + y), (s2, x*y)])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyfuncs.horner">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyfuncs.</span></span><span class="sig-name descname"><span class="pre">horner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyfuncs.py#L148-L199"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyfuncs.horner" title="Permalink to this definition">¶</a></dt>
<dd><p>Rewrite a polynomial in Horner form.</p>
<p>Among other applications, evaluation of a polynomial at a point is optimal
when it is applied using the Horner scheme ([1]).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyfuncs</span> <span class="kn">import</span> <span class="n">horner</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">d</span><span class="p">,</span> <span class="n">e</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">horner</span><span class="p">(</span><span class="mi">9</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">7</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">x*(x*(x*(9*x + 8) + 7) + 6) + 5</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">horner</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">b</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">c</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">d</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">e</span><span class="p">)</span>
<span class="go">e + x*(d + x*(c + x*(a*x + b)))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">horner</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">wrt</span><span class="o">=</span><span class="n">x</span><span class="p">)</span>
<span class="go">x*(x*y*(4*y + 2) + y*(2*y + 1))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">horner</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">wrt</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="go">y*(x*y*(4*x + 2) + x*(2*x + 1))</span>
</pre></div>
</div>
<p class="rubric">References</p>
<p>[1] - <a class="reference external" href="https://en.wikipedia.org/wiki/Horner_scheme">https://en.wikipedia.org/wiki/Horner_scheme</a></p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyfuncs.interpolate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyfuncs.</span></span><span class="sig-name descname"><span class="pre">interpolate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyfuncs.py#L202-L265"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyfuncs.interpolate" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an interpolating polynomial for the data points
evaluated at point x (which can be symbolic or numeric).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyfuncs</span> <span class="kn">import</span> <span class="n">interpolate</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">x</span>
</pre></div>
</div>
<p>A list is interpreted as though it were paired with a range starting
from 1:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">interpolate</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">16</span><span class="p">],</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2</span>
</pre></div>
</div>
<p>This can be made explicit by giving a list of coordinates:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">interpolate</span><span class="p">([(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">9</span><span class="p">)],</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2</span>
</pre></div>
</div>
<p>The (x, y) coordinates can also be given as keys and values of a
dictionary (and the points need not be equispaced):</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">interpolate</span><span class="p">([(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">)],</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">interpolate</span><span class="p">({</span><span class="o">-</span><span class="mi">1</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span> <span class="mi">5</span><span class="p">},</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2 + 1</span>
</pre></div>
</div>
<p>If the interpolation is going to be used only once then the
value of interest can be passed instead of passing a symbol:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">interpolate</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">9</span><span class="p">],</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">25</span>
</pre></div>
</div>
<p>Symbolic coordinates are also supported:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">[(</span><span class="n">i</span><span class="p">,</span><span class="n">interpolate</span><span class="p">((</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">),</span> <span class="n">i</span><span class="p">))</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]</span>
<span class="go">[(1, a), (2, b), (3, -a + 2*b)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyfuncs.viete">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyfuncs.</span></span><span class="sig-name descname"><span class="pre">viete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">roots</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyfuncs.py#L328-L382"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyfuncs.viete" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate Viete’s formulas for <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyfuncs</span> <span class="kn">import</span> <span class="n">viete</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">r1</span><span class="p">,</span> <span class="n">r2</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x,a:c,r1:3&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">viete</span><span class="p">(</span><span class="n">a</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">b</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">c</span><span class="p">,</span> <span class="p">[</span><span class="n">r1</span><span class="p">,</span> <span class="n">r2</span><span class="p">],</span> <span class="n">x</span><span class="p">)</span>
<span class="go">[(r1 + r2, -b/a), (r1*r2, c/a)]</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="domain-constructors">
<h2>Domain constructors<a class="headerlink" href="#domain-constructors" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.constructor.construct_domain">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.constructor.</span></span><span class="sig-name descname"><span class="pre">construct_domain</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">obj</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/constructor.py#L270-L391"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.constructor.construct_domain" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a minimal domain for a list of expressions.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>obj: list or dict</strong></p>
<blockquote>
<div><p>The expressions to build a domain for.</p>
</div></blockquote>
<p><strong>**args: keyword arguments</strong></p>
<blockquote>
<div><p>Options that affect the choice of domain.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>(K, elements): Domain and list of domain elements</p>
<blockquote>
<div><p>The domain K that can represent the expressions and the list or dict
of domain elements representing the same expressions as elements of K.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Explanation</p>
<p>Given a list of normal SymPy expressions (of type <a class="reference internal" href="../core.html#sympy.core.expr.Expr" title="sympy.core.expr.Expr"><code class="xref py py-class docutils literal notranslate"><span class="pre">Expr</span></code></a>)
<code class="docutils literal notranslate"><span class="pre">construct_domain</span></code> will find a minimal <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a> that can
represent those expressions. The expressions will be converted to elements
of the domain and both the domain and the domain elements are returned.</p>
<p class="rubric">Examples</p>
<p>Given a list of <a class="reference internal" href="../core.html#sympy.core.numbers.Integer" title="sympy.core.numbers.Integer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Integer</span></code></a> <code class="docutils literal notranslate"><span class="pre">construct_domain</span></code> will return the
domain <a class="reference internal" href="domainsref.html#zz"><span class="std std-ref">ZZ</span></a> and a list of integers as elements of <a class="reference internal" href="domainsref.html#zz"><span class="std std-ref">ZZ</span></a>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">construct_domain</span><span class="p">,</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">4</span><span class="p">)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">K</span><span class="p">,</span> <span class="n">elements</span> <span class="o">=</span> <span class="n">construct_domain</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">K</span>
<span class="go">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">elements</span>
<span class="go">[2, 3, 4]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">type</span><span class="p">(</span><span class="n">elements</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>  
<span class="go">&lt;class &#39;int&#39;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">type</span><span class="p">(</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="go">&lt;class &#39;sympy.core.numbers.Integer&#39;&gt;</span>
</pre></div>
</div>
<p>If there are any <a class="reference internal" href="../core.html#sympy.core.numbers.Rational" title="sympy.core.numbers.Rational"><code class="xref py py-class docutils literal notranslate"><span class="pre">Rational</span></code></a> then <a class="reference internal" href="domainsref.html#qq"><span class="std std-ref">QQ</span></a> is returned
instead.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">construct_domain</span><span class="p">([</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">/</span><span class="mi">4</span><span class="p">])</span>
<span class="go">(QQ, [1/2, 3/4])</span>
</pre></div>
</div>
<p>If there are symbols then a polynomial ring <a class="reference internal" href="domainsref.html#k-x"><span class="std std-ref">K[x]</span></a> is returned.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x, y&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">construct_domain</span><span class="p">([</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">/</span><span class="mi">4</span><span class="p">])</span>
<span class="go">(QQ[x], [2*x + 1, 3/4])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">construct_domain</span><span class="p">([</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">y</span><span class="p">])</span>
<span class="go">(ZZ[x,y], [2*x + 1, y])</span>
</pre></div>
</div>
<p>If any symbols appear with negative powers then a rational function field
<a class="reference internal" href="domainsref.html#id11"><span class="std std-ref">K(x)</span></a> will be returned.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">construct_domain</span><span class="p">([</span><span class="n">y</span><span class="o">/</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">/</span><span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">y</span><span class="p">)])</span>
<span class="go">(ZZ(x,y), [y/x, -x/(y - 1)])</span>
</pre></div>
</div>
<p>Irrational algebraic numbers will result in the <a class="reference internal" href="domainsref.html#ex"><span class="std std-ref">EX</span></a> domain by
default. The keyword argument <code class="docutils literal notranslate"><span class="pre">extension=True</span></code> leads to the construction
of an algebraic number field <a class="reference internal" href="domainsref.html#qq-a"><span class="std std-ref">QQ&lt;a&gt;</span></a>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">construct_domain</span><span class="p">([</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)])</span>
<span class="go">(EX, [EX(sqrt(2))])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">construct_domain</span><span class="p">([</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="n">extension</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>  
<span class="go">(QQ&lt;sqrt(2)&gt;, [ANP([1, 0], [1, 0, -2], QQ)])</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Domain</span></code></a>, <a class="reference internal" href="../core.html#sympy.core.expr.Expr" title="sympy.core.expr.Expr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Expr</span></code></a></p>
</div>
</dd></dl>

</section>
<section id="algebraic-number-fields">
<h2>Algebraic number fields<a class="headerlink" href="#algebraic-number-fields" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.numberfields.minimal_polynomial">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">minimal_polynomial</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ex</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/numberfields.py#L629-L722"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.minimal_polynomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the minimal polynomial of an algebraic element.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ex</strong> : Expr</p>
<blockquote>
<div><p>Element or expression whose minimal polynomial is to be calculated.</p>
</div></blockquote>
<p><strong>x</strong> : Symbol, optional</p>
<blockquote>
<div><p>Independent variable of the minimal polynomial</p>
</div></blockquote>
<p><strong>compose</strong> : boolean, optional (default=True)</p>
<blockquote>
<div><p>Method to use for computing minimal polynomial. If <code class="docutils literal notranslate"><span class="pre">compose=True</span></code>
(default) then <code class="docutils literal notranslate"><span class="pre">_minpoly_compose</span></code> is used, if <code class="docutils literal notranslate"><span class="pre">compose=False</span></code> then
groebner bases are used.</p>
</div></blockquote>
<p><strong>polys</strong> : boolean, optional (default=False)</p>
<blockquote>
<div><p>If <code class="docutils literal notranslate"><span class="pre">True</span></code> returns a <code class="docutils literal notranslate"><span class="pre">Poly</span></code> object else an <code class="docutils literal notranslate"><span class="pre">Expr</span></code> object.</p>
</div></blockquote>
<p><strong>domain</strong> : Domain, optional</p>
<blockquote>
<div><p>Ground domain</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>By default <code class="docutils literal notranslate"><span class="pre">compose=True</span></code>, the minimal polynomial of the subexpressions of <code class="docutils literal notranslate"><span class="pre">ex</span></code>
are computed, then the arithmetic operations on them are performed using the resultant
and factorization.
If <code class="docutils literal notranslate"><span class="pre">compose=False</span></code>, a bottom-up algorithm is used with <code class="docutils literal notranslate"><span class="pre">groebner</span></code>.
The default algorithm stalls less frequently.</p>
<p>If no ground domain is given, it will be generated automatically from the expression.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">minimal_polynomial</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">solve</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2 - 2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">QQ</span><span class="o">.</span><span class="n">algebraic_field</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)))</span>
<span class="go">x - sqrt(2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**4 - 10*x**2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">solve</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**3 + x + 3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2 - y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.numberfields.minpoly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">minpoly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ex</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/numberfields.py#L629-L722"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.minpoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the minimal polynomial of an algebraic element.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ex</strong> : Expr</p>
<blockquote>
<div><p>Element or expression whose minimal polynomial is to be calculated.</p>
</div></blockquote>
<p><strong>x</strong> : Symbol, optional</p>
<blockquote>
<div><p>Independent variable of the minimal polynomial</p>
</div></blockquote>
<p><strong>compose</strong> : boolean, optional (default=True)</p>
<blockquote>
<div><p>Method to use for computing minimal polynomial. If <code class="docutils literal notranslate"><span class="pre">compose=True</span></code>
(default) then <code class="docutils literal notranslate"><span class="pre">_minpoly_compose</span></code> is used, if <code class="docutils literal notranslate"><span class="pre">compose=False</span></code> then
groebner bases are used.</p>
</div></blockquote>
<p><strong>polys</strong> : boolean, optional (default=False)</p>
<blockquote>
<div><p>If <code class="docutils literal notranslate"><span class="pre">True</span></code> returns a <code class="docutils literal notranslate"><span class="pre">Poly</span></code> object else an <code class="docutils literal notranslate"><span class="pre">Expr</span></code> object.</p>
</div></blockquote>
<p><strong>domain</strong> : Domain, optional</p>
<blockquote>
<div><p>Ground domain</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>By default <code class="docutils literal notranslate"><span class="pre">compose=True</span></code>, the minimal polynomial of the subexpressions of <code class="docutils literal notranslate"><span class="pre">ex</span></code>
are computed, then the arithmetic operations on them are performed using the resultant
and factorization.
If <code class="docutils literal notranslate"><span class="pre">compose=False</span></code>, a bottom-up algorithm is used with <code class="docutils literal notranslate"><span class="pre">groebner</span></code>.
The default algorithm stalls less frequently.</p>
<p>If no ground domain is given, it will be generated automatically from the expression.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">minimal_polynomial</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">solve</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2 - 2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">QQ</span><span class="o">.</span><span class="n">algebraic_field</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)))</span>
<span class="go">x - sqrt(2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**4 - 10*x**2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">solve</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**3 + x + 3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimal_polynomial</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2 - y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.numberfields.primitive_element">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">primitive_element</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">extension</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/numberfields.py#L878-L926"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.primitive_element" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a common number field for all extensions.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.numberfields.field_isomorphism">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">field_isomorphism</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fast</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/numberfields.py#L1037-L1069"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.field_isomorphism" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an isomorphism between two number fields.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.numberfields.to_number_field">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">to_number_field</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">extension</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">theta</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gen</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/numberfields.py#L1072-L1100"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.to_number_field" title="Permalink to this definition">¶</a></dt>
<dd><p>Express <span class="math notranslate nohighlight">\(extension\)</span> in the field generated by <span class="math notranslate nohighlight">\(theta\)</span>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.numberfields.isolate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">isolate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">alg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fast</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/numberfields.py#L1118-L1152"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.isolate" title="Permalink to this definition">¶</a></dt>
<dd><p>Give a rational isolating interval for an algebraic number.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.numberfields.</span></span><span class="sig-name descname"><span class="pre">AlgebraicNumber</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coeffs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alias</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/core/numbers.py#L2512-L2640"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber" title="Permalink to this definition">¶</a></dt>
<dd><p>Class for representing algebraic numbers in SymPy.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber.as_expr">
<span class="sig-name descname"><span class="pre">as_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/core/numbers.py#L2604-L2606"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber.as_expr" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Basic expression from <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber.as_poly">
<span class="sig-name descname"><span class="pre">as_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/core/numbers.py#L2593-L2602"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber.as_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Poly instance from <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber.coeffs">
<span class="sig-name descname"><span class="pre">coeffs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/core/numbers.py#L2608-L2610"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber.coeffs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all SymPy coefficients of an algebraic number.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber.is_aliased">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_aliased</span></span><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber.is_aliased" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">alias</span></code> was set.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber.native_coeffs">
<span class="sig-name descname"><span class="pre">native_coeffs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/core/numbers.py#L2612-L2614"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber.native_coeffs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all native coefficients of an algebraic number.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.numberfields.AlgebraicNumber.to_algebraic_integer">
<span class="sig-name descname"><span class="pre">to_algebraic_integer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/core/numbers.py#L2616-L2630"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.numberfields.AlgebraicNumber.to_algebraic_integer" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert <code class="docutils literal notranslate"><span class="pre">self</span></code> to an algebraic integer.</p>
</dd></dl>

</dd></dl>

</section>
<section id="monomials-encoded-as-tuples">
<h2>Monomials encoded as tuples<a class="headerlink" href="#monomials-encoded-as-tuples" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.monomials.Monomial">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.monomials.</span></span><span class="sig-name descname"><span class="pre">Monomial</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">monom</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gens</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/monomials.py#L511-L636"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.monomials.Monomial" title="Permalink to this definition">¶</a></dt>
<dd><p>Class representing a monomial, i.e. a product of powers.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.monomials.Monomial.as_expr">
<span class="sig-name descname"><span class="pre">as_expr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/monomials.py#L549-L557"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.monomials.Monomial.as_expr" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a monomial instance to a SymPy expression.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.monomials.Monomial.gcd">
<span class="sig-name descname"><span class="pre">gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/monomials.py#L614-L624"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.monomials.Monomial.gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Greatest common divisor of monomials.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.monomials.Monomial.lcm">
<span class="sig-name descname"><span class="pre">lcm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/monomials.py#L626-L636"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.monomials.Monomial.lcm" title="Permalink to this definition">¶</a></dt>
<dd><p>Least common multiple of monomials.</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.monomials.itermonomials">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.monomials.</span></span><span class="sig-name descname"><span class="pre">itermonomials</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">variables</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_degrees</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_degrees</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/monomials.py#L14-L152"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.monomials.itermonomials" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">max_degrees</span></code> and <code class="docutils literal notranslate"><span class="pre">min_degrees</span></code> are either both integers or both lists.
Unless otherwise specified, <code class="docutils literal notranslate"><span class="pre">min_degrees</span></code> is either <code class="docutils literal notranslate"><span class="pre">0</span></code> or
<code class="docutils literal notranslate"><span class="pre">[0,</span> <span class="pre">...,</span> <span class="pre">0]</span></code>.</p>
<p>A generator of all monomials <code class="docutils literal notranslate"><span class="pre">monom</span></code> is returned, such that
either
<code class="docutils literal notranslate"><span class="pre">min_degree</span> <span class="pre">&lt;=</span> <span class="pre">total_degree(monom)</span> <span class="pre">&lt;=</span> <span class="pre">max_degree</span></code>,
or
<code class="docutils literal notranslate"><span class="pre">min_degrees[i]</span> <span class="pre">&lt;=</span> <span class="pre">degree_list(monom)[i]</span> <span class="pre">&lt;=</span> <span class="pre">max_degrees[i]</span></code>,
for all <code class="docutils literal notranslate"><span class="pre">i</span></code>.</p>
<p class="rubric">Case I. <code class="docutils literal notranslate"><span class="pre">max_degrees</span></code> And <code class="docutils literal notranslate"><span class="pre">min_degrees</span></code> Are Both Integers</p>
<p>Given a set of variables <span class="math notranslate nohighlight">\(V\)</span> and a min_degree <span class="math notranslate nohighlight">\(N\)</span> and a max_degree <span class="math notranslate nohighlight">\(M\)</span>
generate a set of monomials of degree less than or equal to <span class="math notranslate nohighlight">\(N\)</span> and greater
than or equal to <span class="math notranslate nohighlight">\(M\)</span>. The total number of monomials in commutative
variables is huge and is given by the following formula if <span class="math notranslate nohighlight">\(M = 0\)</span>:</p>
<blockquote>
<div><div class="math notranslate nohighlight">
\[\frac{(\#V + N)!}{\#V! N!}\]</div>
</div></blockquote>
<p>For example if we would like to generate a dense polynomial of
a total degree <span class="math notranslate nohighlight">\(N = 50\)</span> and <span class="math notranslate nohighlight">\(M = 0\)</span>, which is the worst case, in 5
variables, assuming that exponents and all of coefficients are 32-bit long
and stored in an array we would need almost 80 GiB of memory! Fortunately
most polynomials, that we will encounter, are sparse.</p>
<p>Consider monomials in commutative variables <span class="math notranslate nohighlight">\(x\)</span> and <span class="math notranslate nohighlight">\(y\)</span>
and non-commutative variables <span class="math notranslate nohighlight">\(a\)</span> and <span class="math notranslate nohighlight">\(b\)</span>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.monomials</span> <span class="kn">import</span> <span class="n">itermonomials</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.orderings</span> <span class="kn">import</span> <span class="n">monomial_key</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>

<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">itermonomials</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">],</span> <span class="mi">2</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="n">monomial_key</span><span class="p">(</span><span class="s1">&#39;grlex&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">]))</span>
<span class="go">[1, x, y, x**2, x*y, y**2]</span>

<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">itermonomials</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="n">monomial_key</span><span class="p">(</span><span class="s1">&#39;grlex&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">]))</span>
<span class="go">[1, x, y, x**2, x*y, y**2, x**3, x**2*y, x*y**2, y**3]</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;a, b&#39;</span><span class="p">,</span> <span class="n">commutative</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">set</span><span class="p">(</span><span class="n">itermonomials</span><span class="p">([</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">x</span><span class="p">],</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">{1, a, a**2, b, b**2, x, x**2, a*b, b*a, x*a, x*b}</span>

<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">itermonomials</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="n">monomial_key</span><span class="p">(</span><span class="s1">&#39;grlex&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">]))</span>
<span class="go">[x, y, x**2, x*y, y**2]</span>
</pre></div>
</div>
<p class="rubric">Case Ii. <code class="docutils literal notranslate"><span class="pre">max_degrees</span></code> And <code class="docutils literal notranslate"><span class="pre">min_degrees</span></code> Are Both Lists</p>
<p>If <code class="docutils literal notranslate"><span class="pre">max_degrees</span> <span class="pre">=</span> <span class="pre">[d_1,</span> <span class="pre">...,</span> <span class="pre">d_n]</span></code> and
<code class="docutils literal notranslate"><span class="pre">min_degrees</span> <span class="pre">=</span> <span class="pre">[e_1,</span> <span class="pre">...,</span> <span class="pre">e_n]</span></code>, the number of monomials generated
is:</p>
<div class="math notranslate nohighlight">
\[(d_1 - e_1 + 1) (d_2 - e_2 + 1) \cdots (d_n - e_n + 1)\]</div>
<p>Let us generate all monomials <code class="docutils literal notranslate"><span class="pre">monom</span></code> in variables <span class="math notranslate nohighlight">\(x\)</span> and <span class="math notranslate nohighlight">\(y\)</span>
such that <code class="docutils literal notranslate"><span class="pre">[1,</span> <span class="pre">2][i]</span> <span class="pre">&lt;=</span> <span class="pre">degree_list(monom)[i]</span> <span class="pre">&lt;=</span> <span class="pre">[2,</span> <span class="pre">4][i]</span></code>,
<code class="docutils literal notranslate"><span class="pre">i</span> <span class="pre">=</span> <span class="pre">0,</span> <span class="pre">1</span></code></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.monomials</span> <span class="kn">import</span> <span class="n">itermonomials</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.orderings</span> <span class="kn">import</span> <span class="n">monomial_key</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>

<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">itermonomials</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]),</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="n">monomial_key</span><span class="p">(</span><span class="s1">&#39;lex&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]))</span>
<span class="go">[x**2*y**4, x**2*y**3, x**2*y**2, x*y**4, x*y**3, x*y**2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.monomials.monomial_count">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.monomials.</span></span><span class="sig-name descname"><span class="pre">monomial_count</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">V</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">N</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/monomials.py#L154-L185"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.monomials.monomial_count" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the number of monomials.</p>
<p>The number of monomials is given by the following formula:</p>
<div class="math notranslate nohighlight">
\[\frac{(\#V + N)!}{\#V! N!}\]</div>
<p>where <span class="math notranslate nohighlight">\(N\)</span> is a total degree and <span class="math notranslate nohighlight">\(V\)</span> is a set of variables.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.monomials</span> <span class="kn">import</span> <span class="n">itermonomials</span><span class="p">,</span> <span class="n">monomial_count</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.orderings</span> <span class="kn">import</span> <span class="n">monomial_key</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">monomial_count</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">M</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">itermonomials</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">],</span> <span class="mi">2</span><span class="p">))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">M</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="n">monomial_key</span><span class="p">(</span><span class="s1">&#39;grlex&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">]))</span>
<span class="go">[1, x, y, x**2, x*y, y**2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">M</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="orderings-of-monomials">
<h2>Orderings of monomials<a class="headerlink" href="#orderings-of-monomials" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.orderings.MonomialOrder">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.orderings.</span></span><span class="sig-name descname"><span class="pre">MonomialOrder</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orderings.py#L11-L34"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orderings.MonomialOrder" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for monomial orderings.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.orderings.LexOrder">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.orderings.</span></span><span class="sig-name descname"><span class="pre">LexOrder</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orderings.py#L36-L44"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orderings.LexOrder" title="Permalink to this definition">¶</a></dt>
<dd><p>Lexicographic order of monomials.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.orderings.GradedLexOrder">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.orderings.</span></span><span class="sig-name descname"><span class="pre">GradedLexOrder</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orderings.py#L46-L53"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orderings.GradedLexOrder" title="Permalink to this definition">¶</a></dt>
<dd><p>Graded lexicographic order of monomials.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.orderings.ReversedGradedLexOrder">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.orderings.</span></span><span class="sig-name descname"><span class="pre">ReversedGradedLexOrder</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orderings.py#L55-L62"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orderings.ReversedGradedLexOrder" title="Permalink to this definition">¶</a></dt>
<dd><p>Reversed graded lexicographic order of monomials.</p>
</dd></dl>

</section>
<section id="formal-manipulation-of-roots-of-polynomials">
<h2>Formal manipulation of roots of polynomials<a class="headerlink" href="#formal-manipulation-of-roots-of-polynomials" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.rootof">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.rootoftools.</span></span><span class="sig-name descname"><span class="pre">rootof</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expand</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L128-L148"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.rootof" title="Permalink to this definition">¶</a></dt>
<dd><p>An indexed root of a univariate polynomial.</p>
<p>Returns either a <a class="reference internal" href="#sympy.polys.rootoftools.ComplexRootOf" title="sympy.polys.rootoftools.ComplexRootOf"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ComplexRootOf</span></code></a> object or an explicit
expression involving radicals.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>Univariate polynomial.</p>
</div></blockquote>
<p><strong>x</strong> : Symbol, optional</p>
<blockquote>
<div><p>Generator for <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</div></blockquote>
<p><strong>index</strong> : int or Integer</p>
<p><strong>radicals</strong> : bool</p>
<blockquote>
<div><p>Return a radical expression if possible.</p>
</div></blockquote>
<p><strong>expand</strong> : bool</p>
<blockquote>
<div><p>Expand <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.RootOf">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.rootoftools.</span></span><span class="sig-name descname"><span class="pre">RootOf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expand</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L151-L163"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.RootOf" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a root of a univariate polynomial.</p>
<p>Base class for roots of different kinds of polynomials.
Only complex roots are currently supported.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.rootoftools.</span></span><span class="sig-name descname"><span class="pre">ComplexRootOf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expand</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L165-L972"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents an indexed complex root of a polynomial.</p>
<p>Roots of a univariate polynomial separated into disjoint
real or complex intervals and indexed in a fixed order.
Currently only rational coefficients are allowed.
Can be imported as <code class="docutils literal notranslate"><span class="pre">CRootOf</span></code>. To avoid confusion, the
generator must be a Symbol.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">CRootOf</span><span class="p">,</span> <span class="n">rootof</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<p>CRootOf is a way to reference a particular root of a
polynomial. If there is a rational root, it will be returned:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">CRootOf</span><span class="o">.</span><span class="n">clear_cache</span><span class="p">()</span>  <span class="c1"># for doctest reproducibility</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">CRootOf</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">-2</span>
</pre></div>
</div>
<p>Whether roots involving radicals are returned or not
depends on whether the <code class="docutils literal notranslate"><span class="pre">radicals</span></code> flag is true (which is
set to True with rootof):</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">CRootOf</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">CRootOf(x**2 - 3, 0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">CRootOf</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">radicals</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">-sqrt(3)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rootof</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">-sqrt(3)</span>
</pre></div>
</div>
<p>The following cannot be expressed in terms of radicals:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">rootof</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">16</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> <span class="n">r</span>
<span class="go">CRootOf(4*x**5 + 16*x**3 + 12*x**2 + 7, 0)</span>
</pre></div>
</div>
<p>The root bounds can be seen, however, and they are used by the
evaluation methods to get numerical approximations for the root.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">interval</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">_get_interval</span><span class="p">();</span> <span class="n">interval</span>
<span class="go">(-1, 0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">evalf</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">-0.98</span>
</pre></div>
</div>
<p>The evalf method refines the width of the root bounds until it
guarantees that any decimal approximation within those bounds
will satisfy the desired precision. It then stores the refined
interval so subsequent requests at or below the requested
precision will not have to recompute the root bounds and will
return very quickly.</p>
<p>Before evaluation above, the interval was</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">interval</span>
<span class="go">(-1, 0)</span>
</pre></div>
</div>
<p>After evaluation it is now</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">_get_interval</span><span class="p">()</span> 
<span class="go">(-165/169, -206/211)</span>
</pre></div>
</div>
<p>To reset all intervals for a given polynomial, the <a class="reference internal" href="#sympy.polys.rootoftools.ComplexRootOf._reset" title="sympy.polys.rootoftools.ComplexRootOf._reset"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_reset()</span></code></a> method
can be called from any CRootOf instance of the polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">_reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">_get_interval</span><span class="p">()</span>
<span class="go">(-1, 0)</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#sympy.polys.rootoftools.ComplexRootOf.eval_approx" title="sympy.polys.rootoftools.ComplexRootOf.eval_approx"><code class="xref py py-meth docutils literal notranslate"><span class="pre">eval_approx()</span></code></a> method will also find the root to a given
precision but the interval is not modified unless the search
for the root fails to converge within the root bounds. And
the secant method is used to find the root. (The <code class="docutils literal notranslate"><span class="pre">evalf</span></code>
method uses bisection and will always update the interval.)</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">eval_approx</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">-0.98</span>
</pre></div>
</div>
<p>The interval needed to be slightly updated to find that root:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">_get_interval</span><span class="p">()</span>
<span class="go">(-1, -1/2)</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">evalf_rational</span></code> will compute a rational approximation
of the root to the desired accuracy or precision.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">eval_rational</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">-69629/71318</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">CRootOf</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">10</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span><span class="o">.</span><span class="n">eval_rational</span><span class="p">(</span><span class="mf">1e-1</span><span class="p">)</span>
<span class="go">15/256 - 805*I/256</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span><span class="o">.</span><span class="n">eval_rational</span><span class="p">(</span><span class="mf">1e-1</span><span class="p">,</span> <span class="mf">1e-4</span><span class="p">)</span>
<span class="go">3275/65536 - 414645*I/131072</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span><span class="o">.</span><span class="n">eval_rational</span><span class="p">(</span><span class="mf">1e-4</span><span class="p">,</span> <span class="mf">1e-4</span><span class="p">)</span>
<span class="go">6545/131072 - 414645*I/131072</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span><span class="o">.</span><span class="n">eval_rational</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">104755/2097152 - 6634255*I/2097152</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>Although a PurePoly can be constructed from a non-symbol generator
RootOf instances of non-symbols are disallowed to avoid confusion
over what root is being represented.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">exp</span><span class="p">,</span> <span class="n">PurePoly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePoly</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="n">PurePoly</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">CRootOf</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">CRootOf</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>  <span class="c1"># would correspond to x == 0</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">sympy.polys.polyerrors.PolynomialError</span>: <span class="n">generator must be a Symbol</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.rootoftools.ComplexRootOf.eval_approx" title="sympy.polys.rootoftools.ComplexRootOf.eval_approx"><code class="xref py py-obj docutils literal notranslate"><span class="pre">eval_approx</span></code></a>, <a class="reference internal" href="#sympy.polys.rootoftools.ComplexRootOf.eval_rational" title="sympy.polys.rootoftools.ComplexRootOf.eval_rational"><code class="xref py py-obj docutils literal notranslate"><span class="pre">eval_rational</span></code></a></p>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._all_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_all_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_cache</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L668-L687"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._all_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Get real and complex roots of a composite polynomial.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._complexes_index">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_complexes_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">complexes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L607-L626"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._complexes_index" title="Permalink to this definition">¶</a></dt>
<dd><p>Map initial complex root index to an index in a factor where
the root belongs.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._complexes_sorted">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_complexes_sorted</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">complexes</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L556-L585"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._complexes_sorted" title="Permalink to this definition">¶</a></dt>
<dd><p>Make complex isolating intervals disjoint and sort roots.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._count_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_count_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">roots</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L628-L631"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._count_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Count the number of real or complex roots with multiplicities.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._eval_evalf">
<span class="sig-name descname"><span class="pre">_eval_evalf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prec</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L887-L890"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._eval_evalf" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate this complex root to the given precision.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._eval_is_imaginary">
<span class="sig-name descname"><span class="pre">_eval_is_imaginary</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L395-L400"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._eval_is_imaginary" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the root is imaginary.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._eval_is_real">
<span class="sig-name descname"><span class="pre">_eval_is_real</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L391-L393"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._eval_is_real" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the root is real.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._get_complexes">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_get_complexes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">factors</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_cache</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L454-L471"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._get_complexes" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute complex root isolating intervals for a list of factors.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._get_complexes_sqf">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_get_complexes_sqf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">currentfactor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_cache</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L424-L433"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._get_complexes_sqf" title="Permalink to this definition">¶</a></dt>
<dd><p>Get complex root isolating intervals for a square-free factor.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._get_interval">
<span class="sig-name descname"><span class="pre">_get_interval</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L775-L781"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._get_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Internal function for retrieving isolation interval from cache.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._get_reals">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_get_reals</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">factors</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_cache</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L435-L452"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._get_reals" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute real root isolating intervals for a list of factors.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._get_reals_sqf">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_get_reals_sqf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">currentfactor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_cache</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L412-L422"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._get_reals_sqf" title="Permalink to this definition">¶</a></dt>
<dd><p>Get real root isolating intervals for a square-free factor.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._get_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_get_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">method</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L734-L755"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._get_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Return postprocessed roots of specified kind.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._indexed_root">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_indexed_root</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L633-L645"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._indexed_root" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a root of a composite polynomial by index.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._new">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_new</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L357-L371"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._new" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct new <code class="docutils literal notranslate"><span class="pre">CRootOf</span></code> object from raw data.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._postprocess_root">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_postprocess_root</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">root</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L723-L732"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._postprocess_root" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the root if it is trivial or a <code class="docutils literal notranslate"><span class="pre">CRootOf</span></code> object.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._preprocess_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_preprocess_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L706-L721"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._preprocess_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Take heroic measures to make <code class="docutils literal notranslate"><span class="pre">poly</span></code> compatible with <code class="docutils literal notranslate"><span class="pre">CRootOf</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._real_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_real_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L647-L660"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._real_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Get real roots of a composite polynomial.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._reals_index">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_reals_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L587-L605"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._reals_index" title="Permalink to this definition">¶</a></dt>
<dd><p>Map initial real root index to an index in a factor where
the root belongs.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._reals_sorted">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_reals_sorted</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">reals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L473-L496"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._reals_sorted" title="Permalink to this definition">¶</a></dt>
<dd><p>Make real isolating intervals disjoint and sort roots.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._refine_complexes">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_refine_complexes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">complexes</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L527-L554"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._refine_complexes" title="Permalink to this definition">¶</a></dt>
<dd><p>return complexes such that no bounding rectangles of non-conjugate
roots would intersect. In addition, assure that neither ay nor by is
0 to guarantee that non-real roots are distinct from real roots in
terms of the y-bounds.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._reset">
<span class="sig-name descname"><span class="pre">_reset</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L662-L666"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset all intervals</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._roots_trivial">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">_roots_trivial</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L689-L704"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._roots_trivial" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute roots in linear, quadratic and binomial cases.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf._set_interval">
<span class="sig-name descname"><span class="pre">_set_interval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">interval</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L783-L789"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf._set_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Internal function for updating isolation interval in cache.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf.all_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">all_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L407-L410"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf.all_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Get real and complex roots of a polynomial.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf.clear_cache">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">clear_cache</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L757-L773"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf.clear_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset cache for reals and complexes.</p>
<p>The intervals used to approximate a root instance are updated
as needed. When a request is made to see the intervals, the
most current values are shown. <span class="math notranslate nohighlight">\(clear_cache\)</span> will reset all
CRootOf instances back to their original state.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.rootoftools.ComplexRootOf._reset" title="sympy.polys.rootoftools.ComplexRootOf._reset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">_reset</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf.eval_approx">
<span class="sig-name descname"><span class="pre">eval_approx</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L801-L885"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf.eval_approx" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate this complex root to the given precision.</p>
<p>This uses secant method and root bounds are used to both
generate an initial guess and to check that the root
returned is valid. If ever the method converges outside the
root bounds, the bounds will be made smaller and updated.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf.eval_rational">
<span class="sig-name descname"><span class="pre">eval_rational</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dx</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">15</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L892-L972"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf.eval_rational" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a Rational approximation of <code class="docutils literal notranslate"><span class="pre">self</span></code> that has real
and imaginary component approximations that are within <code class="docutils literal notranslate"><span class="pre">dx</span></code>
and <code class="docutils literal notranslate"><span class="pre">dy</span></code> of the true values, respectively. Alternatively,
<code class="docutils literal notranslate"><span class="pre">n</span></code> digits of precision can be specified.</p>
<p>The interval is refined with bisection and is sure to
converge. The root bounds are updated when the refinement
is complete so recalculation at the same or lesser precision
will not have to repeat the refinement and should be much
faster.</p>
<p>The following example first obtains Rational approximation to
1e-8 accuracy for all roots of the 4-th order Legendre
polynomial. Since the roots are all less than 1, this will
ensure the decimal representation of the approximation will be
correct (including rounding) to 6 digits:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">legendre_poly</span><span class="p">,</span> <span class="n">Symbol</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">legendre_poly</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">polys</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">real_roots</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">eval_rational</span><span class="p">(</span><span class="mi">10</span><span class="o">**-</span><span class="mi">8</span><span class="p">)</span><span class="o">.</span><span class="n">n</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span>
<span class="go">0.861136</span>
</pre></div>
</div>
<p>It is not necessary to a two-step calculation, however: the
decimal representation can be computed directly:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">evalf</span><span class="p">(</span><span class="mi">17</span><span class="p">)</span>
<span class="go">0.86113631159405258</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.ComplexRootOf.real_roots">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">real_roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radicals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L402-L405"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.ComplexRootOf.real_roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Get real roots of a polynomial.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.RootSum">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.rootoftools.</span></span><span class="sig-name descname"><span class="pre">RootSum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quadratic</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L1016-L1213"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.RootSum" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a sum of all roots of a univariate polynomial.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.rootoftools.RootSum.new">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">new</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rootoftools.py#L1093-L1104"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rootoftools.RootSum.new" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct new <code class="docutils literal notranslate"><span class="pre">RootSum</span></code> instance.</p>
</dd></dl>

</dd></dl>

</section>
<section id="symbolic-root-finding-algorithms">
<h2>Symbolic root-finding algorithms<a class="headerlink" href="#symbolic-root-finding-algorithms" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyroots.roots">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyroots.</span></span><span class="sig-name descname"><span class="pre">roots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubics</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">trig</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quartics</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quintics</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">multiple</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">predicate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">flags</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyroots.py#L795-L1094"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyroots.roots" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes symbolic roots of a univariate polynomial.</p>
<p>Given a univariate polynomial f with symbolic coefficients (or
a list of the polynomial’s coefficients), returns a dictionary
with its roots and their multiplicities.</p>
<p>Only roots expressible via radicals will be returned.  To get
a complete set of roots use RootOf class or numerical methods
instead. By default cubic and quartic formulas are used in
the algorithm. To disable them because of unreadable output
set <code class="docutils literal notranslate"><span class="pre">cubics=False</span></code> or <code class="docutils literal notranslate"><span class="pre">quartics=False</span></code> respectively. If cubic
roots are real but are expressed in terms of complex numbers
(casus irreducibilis [1]) the <code class="docutils literal notranslate"><span class="pre">trig</span></code> flag can be set to True to
have the solutions returned in terms of cosine and inverse cosine
functions.</p>
<p>To get roots from a specific domain set the <code class="docutils literal notranslate"><span class="pre">filter</span></code> flag with
one of the following specifiers: Z, Q, R, I, C. By default all
roots are returned (this is equivalent to setting <code class="docutils literal notranslate"><span class="pre">filter='C'</span></code>).</p>
<p>By default a dictionary is returned giving a compact result in
case of multiple roots.  However to get a list containing all
those roots set the <code class="docutils literal notranslate"><span class="pre">multiple</span></code> flag to True; the list will
have identical roots appearing next to each other in the result.
(For a given Poly, the all_roots method will give the roots in
sorted numerical order.)</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">roots</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">roots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">{-1: 1, 1: 1}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">roots</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="go">{-1: 1, 1: 1}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">roots</span><span class="p">(</span><span class="n">Poly</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="go">{-sqrt(y): 1, sqrt(y): 1}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">roots</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">{-sqrt(y): 1, sqrt(y): 1}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">roots</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>
<span class="go">{-1: 1, 1: 1}</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r664"><span class="brackets"><a class="fn-backref" href="#id24">R664</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Cubic_function#Trigonometric_.28and_hyperbolic.29_method">https://en.wikipedia.org/wiki/Cubic_function#Trigonometric_.28and_hyperbolic.29_method</a></p>
</dd>
</dl>
</dd></dl>

</section>
<section id="special-polynomials">
<h2>Special polynomials<a class="headerlink" href="#special-polynomials" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.specialpolys.swinnerton_dyer_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.specialpolys.</span></span><span class="sig-name descname"><span class="pre">swinnerton_dyer_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/specialpolys.py#L24-L62"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.specialpolys.swinnerton_dyer_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates n-th Swinnerton-Dyer polynomial in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the order of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.specialpolys.interpolating_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.specialpolys.</span></span><span class="sig-name descname"><span class="pre">interpolating_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'x'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'y'</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/specialpolys.py#L142-L173"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.specialpolys.interpolating_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct Lagrange interpolating polynomial for <code class="docutils literal notranslate"><span class="pre">n</span></code>
data points. If a sequence of values are given for <code class="docutils literal notranslate"><span class="pre">X</span></code> and <code class="docutils literal notranslate"><span class="pre">Y</span></code>
then the first <code class="docutils literal notranslate"><span class="pre">n</span></code> values will be used.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.specialpolys.cyclotomic_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.specialpolys.</span></span><span class="sig-name descname"><span class="pre">cyclotomic_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/specialpolys.py#L65-L89"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.specialpolys.cyclotomic_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates cyclotomic polynomial of order <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the order of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.specialpolys.symmetric_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.specialpolys.</span></span><span class="sig-name descname"><span class="pre">symmetric_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/specialpolys.py#L92-L112"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.specialpolys.symmetric_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates symmetric polynomial of order <span class="math notranslate nohighlight">\(n\)</span>.</p>
<p>Returns a Poly object when <code class="docutils literal notranslate"><span class="pre">polys=True</span></code>, otherwise
(default) returns an expression.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.specialpolys.random_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.specialpolys.</span></span><span class="sig-name descname"><span class="pre">random_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inf</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sup</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">ZZ</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/specialpolys.py#L115-L139"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.specialpolys.random_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates a polynomial of degree <code class="docutils literal notranslate"><span class="pre">n</span></code> with coefficients in
<code class="docutils literal notranslate"><span class="pre">[inf,</span> <span class="pre">sup]</span></code>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x</strong></p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(x\)</span> is the independent term of polynomial</p>
</div></blockquote>
<p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the order of polynomial</p>
</div></blockquote>
<p><strong>inf</strong></p>
<blockquote>
<div><p>Lower limit of range in which coefficients lie</p>
</div></blockquote>
<p><strong>sup</strong></p>
<blockquote>
<div><p>Upper limit of range in which coefficients lie</p>
</div></blockquote>
<p><strong>domain</strong> : optional</p>
<blockquote>
<div><p>Decides what ring the coefficients are supposed
to belong. Default is set to Integers.</p>
</div></blockquote>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

</section>
<section id="orthogonal-polynomials">
<h2>Orthogonal polynomials<a class="headerlink" href="#orthogonal-polynomials" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.chebyshevt_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">chebyshevt_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L122-L147"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.chebyshevt_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Chebyshev polynomial of the first kind of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.chebyshevu_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">chebyshevu_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L161-L186"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.chebyshevu_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Chebyshev polynomial of the second kind of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.gegenbauer_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">gegenbauer_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L80-L108"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.gegenbauer_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Gegenbauer polynomial of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>a</strong></p>
<blockquote>
<div><p>Decides minimal domain for the list of
coefficients.</p>
</div></blockquote>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.hermite_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">hermite_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L204-L228"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.hermite_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Hermite polynomial of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.jacobi_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">jacobi_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L32-L63"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.jacobi_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Jacobi polynomial of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>a</strong></p>
<blockquote>
<div><p>Lower limit of minimal domain for the list of
coefficients.</p>
</div></blockquote>
<p><strong>b</strong></p>
<blockquote>
<div><p>Upper limit of minimal domain for the list of
coefficients.</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.legendre_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">legendre_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L244-L268"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.legendre_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Legendre polynomial of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.laguerre_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">laguerre_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L284-L317"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.laguerre_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates Laguerre polynomial of degree <span class="math notranslate nohighlight">\(n\)</span> in <span class="math notranslate nohighlight">\(x\)</span>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>alpha</strong></p>
<blockquote>
<div><p>Decides minimal domain for the list
of coefficients.</p>
</div></blockquote>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.orthopolys.spherical_bessel_fn">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.orthopolys.</span></span><span class="sig-name descname"><span class="pre">spherical_bessel_fn</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">polys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/orthopolys.py#L342-L393"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.orthopolys.spherical_bessel_fn" title="Permalink to this definition">¶</a></dt>
<dd><p>Coefficients for the spherical Bessel functions.</p>
<p>Those are only needed in the jn() function.</p>
<p>The coefficients are calculated from:</p>
<p>fn(0, z) = 1/z
fn(1, z) = 1/z**2
fn(n-1, z) + fn(n+1, z) == (2*n+1)/z * fn(n, z)</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>n</strong> : int</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(n\)</span> decides the degree of polynomial</p>
</div></blockquote>
<p><strong>x</strong> : optional</p>
<p><strong>polys</strong> : bool, optional</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">polys=True</span></code> returns an expression, otherwise
(default) returns an expression.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.orthopolys</span> <span class="kn">import</span> <span class="n">spherical_bessel_fn</span> <span class="k">as</span> <span class="n">fn</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s2">&quot;z&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fn</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">z**(-2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fn</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">-1/z + 3/z**3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fn</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">-6/z**2 + 15/z**4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fn</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">1/z - 45/z**3 + 105/z**5</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="manipulation-of-rational-functions">
<h2>Manipulation of rational functions<a class="headerlink" href="#manipulation-of-rational-functions" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.rationaltools.together">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.rationaltools.</span></span><span class="sig-name descname"><span class="pre">together</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">deep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fraction</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/rationaltools.py#L9-L84"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.rationaltools.together" title="Permalink to this definition">¶</a></dt>
<dd><p>Denest and combine rational expressions using symbolic methods.</p>
<p>This function takes an expression or a container of expressions
and puts it (them) together by denesting and combining rational
subexpressions. No heroic measures are taken to minimize degree
of the resulting numerator and denominator. To obtain completely
reduced expression use <a class="reference internal" href="#sympy.polys.polytools.cancel" title="sympy.polys.polytools.cancel"><code class="xref py py-func docutils literal notranslate"><span class="pre">cancel()</span></code></a>. However, <a class="reference internal" href="#sympy.polys.rationaltools.together" title="sympy.polys.rationaltools.together"><code class="xref py py-func docutils literal notranslate"><span class="pre">together()</span></code></a>
can preserve as much as possible of the structure of the input
expression in the output (no expansion is performed).</p>
<p>A wide variety of objects can be put together including lists,
tuples, sets, relational objects, integrals and others. It is
also possible to transform interior of function applications,
by setting <code class="docutils literal notranslate"><span class="pre">deep</span></code> flag to <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p>
<p>By definition, <a class="reference internal" href="#sympy.polys.rationaltools.together" title="sympy.polys.rationaltools.together"><code class="xref py py-func docutils literal notranslate"><span class="pre">together()</span></code></a> is a complement to <a class="reference internal" href="#sympy.polys.partfrac.apart" title="sympy.polys.partfrac.apart"><code class="xref py py-func docutils literal notranslate"><span class="pre">apart()</span></code></a>,
so <code class="docutils literal notranslate"><span class="pre">apart(together(expr))</span></code> should return expr unchanged. Note
however, that <a class="reference internal" href="#sympy.polys.rationaltools.together" title="sympy.polys.rationaltools.together"><code class="xref py py-func docutils literal notranslate"><span class="pre">together()</span></code></a> uses only symbolic methods, so
it might be necessary to use <a class="reference internal" href="#sympy.polys.polytools.cancel" title="sympy.polys.polytools.cancel"><code class="xref py py-func docutils literal notranslate"><span class="pre">cancel()</span></code></a> to perform algebraic
simplification and minimize degree of the numerator and denominator.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">together</span><span class="p">,</span> <span class="n">exp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">y</span><span class="p">)</span>
<span class="go">(x + y)/(x*y)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">z</span><span class="p">)</span>
<span class="go">(x*y + x*z + y*z)/(x*y*z)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">(x + y)/(x*y**2)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">y</span><span class="p">))</span>
<span class="go">(x*(y + 1) + y*(x + 1))/((x + 1)*(y + 1))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">y</span><span class="p">))</span>
<span class="go">exp(1/y + 1/x)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">y</span><span class="p">),</span> <span class="n">deep</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">exp((x + y)/(x*y))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">)))</span>
<span class="go">(x + 1)*exp(-x)/x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">together</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">exp</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">)))</span>
<span class="go">(x*exp(x) + 1)*exp(-3*x)/x</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="partial-fraction-decomposition">
<h2>Partial fraction decomposition<a class="headerlink" href="#partial-fraction-decomposition" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.partfrac.apart">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.partfrac.</span></span><span class="sig-name descname"><span class="pre">apart</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">full</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">options</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/partfrac.py#L13-L147"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.partfrac.apart" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute partial fraction decomposition of a rational function.</p>
<p>Given a rational function <code class="docutils literal notranslate"><span class="pre">f</span></code>, computes the partial fraction
decomposition of <code class="docutils literal notranslate"><span class="pre">f</span></code>. Two algorithms are available: One is based on the
undertermined coefficients method, the other is Bronstein’s full partial
fraction decomposition algorithm.</p>
<p>The undetermined coefficients method (selected by <code class="docutils literal notranslate"><span class="pre">full=False</span></code>) uses
polynomial factorization (and therefore accepts the same options as
factor) for the denominator. Per default it works over the rational
numbers, therefore decomposition of denominators with non-rational roots
(e.g. irrational, complex roots) is not supported by default (see options
of factor).</p>
<p>Bronstein’s algorithm can be selected by using <code class="docutils literal notranslate"><span class="pre">full=True</span></code> and allows a
decomposition of denominators with non-rational roots. A human-readable
result can be obtained via <code class="docutils literal notranslate"><span class="pre">doit()</span></code> (see examples below).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.partfrac</span> <span class="kn">import</span> <span class="n">apart</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<p>By default, using the undetermined coefficients method:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">apart</span><span class="p">(</span><span class="n">y</span><span class="o">/</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">-y/(x + 2) + y/(x + 1)</span>
</pre></div>
</div>
<p>The undetermined coefficients method does not provide a result when the
denominators roots are not rational:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">apart</span><span class="p">(</span><span class="n">y</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">y/(x**2 + x + 1)</span>
</pre></div>
</div>
<p>You can choose Bronstein’s algorithm by setting <code class="docutils literal notranslate"><span class="pre">full=True</span></code>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">apart</span><span class="p">(</span><span class="n">y</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">full</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">RootSum(_w**2 + _w + 1, Lambda(_a, (-2*_a*y/3 - y/3)/(-_a + x)))</span>
</pre></div>
</div>
<p>Calling <code class="docutils literal notranslate"><span class="pre">doit()</span></code> yields a human-readable result:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">apart</span><span class="p">(</span><span class="n">y</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">full</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">doit</span><span class="p">()</span>
<span class="go">(-y/3 - 2*y*(-1/2 - sqrt(3)*I/2)/3)/(x + 1/2 + sqrt(3)*I/2) + (-y/3 -</span>
<span class="go">    2*y*(-1/2 + sqrt(3)*I/2)/3)/(x + 1/2 - sqrt(3)*I/2)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.partfrac.apart_list" title="sympy.polys.partfrac.apart_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">apart_list</span></code></a>, <a class="reference internal" href="#sympy.polys.partfrac.assemble_partfrac_list" title="sympy.polys.partfrac.assemble_partfrac_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assemble_partfrac_list</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.partfrac.apart_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.partfrac.</span></span><span class="sig-name descname"><span class="pre">apart_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dummies</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">options</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/partfrac.py#L211-L349"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.partfrac.apart_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute partial fraction decomposition of a rational function
and return the result in structured form.</p>
<p>Given a rational function <code class="docutils literal notranslate"><span class="pre">f</span></code> compute the partial fraction decomposition
of <code class="docutils literal notranslate"><span class="pre">f</span></code>. Only Bronstein’s full partial fraction decomposition algorithm
is supported by this method. The return value is highly structured and
perfectly suited for further algorithmic treatment rather than being
human-readable. The function returns a tuple holding three elements:</p>
<ul class="simple">
<li><p>The first item is the common coefficient, free of the variable <span class="math notranslate nohighlight">\(x\)</span> used
for decomposition. (It is an element of the base field <span class="math notranslate nohighlight">\(K\)</span>.)</p></li>
<li><p>The second item is the polynomial part of the decomposition. This can be
the zero polynomial. (It is an element of <span class="math notranslate nohighlight">\(K[x]\)</span>.)</p></li>
<li><p>The third part itself is a list of quadruples. Each quadruple
has the following elements in this order:</p>
<ul>
<li><p>The (not necessarily irreducible) polynomial <span class="math notranslate nohighlight">\(D\)</span> whose roots <span class="math notranslate nohighlight">\(w_i\)</span> appear
in the linear denominator of a bunch of related fraction terms. (This item
can also be a list of explicit roots. However, at the moment <code class="docutils literal notranslate"><span class="pre">apart_list</span></code>
never returns a result this way, but the related <code class="docutils literal notranslate"><span class="pre">assemble_partfrac_list</span></code>
function accepts this format as input.)</p></li>
<li><p>The numerator of the fraction, written as a function of the root <span class="math notranslate nohighlight">\(w\)</span></p></li>
<li><p>The linear denominator of the fraction <em>excluding its power exponent</em>,
written as a function of the root <span class="math notranslate nohighlight">\(w\)</span>.</p></li>
<li><p>The power to which the denominator has to be raised.</p></li>
</ul>
</li>
</ul>
<p>On can always rebuild a plain expression by using the function <code class="docutils literal notranslate"><span class="pre">assemble_partfrac_list</span></code>.</p>
<p class="rubric">Examples</p>
<p>A first example:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.partfrac</span> <span class="kn">import</span> <span class="n">apart_list</span><span class="p">,</span> <span class="n">assemble_partfrac_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">t</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="n">apart_list</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span>
<span class="go">(1,</span>
<span class="go">Poly(2*x + 4, x, domain=&#39;ZZ&#39;),</span>
<span class="go">[(Poly(_w - 1, _w, domain=&#39;ZZ&#39;), Lambda(_a, 4), Lambda(_a, -_a + x), 1)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="go">2*x + 4 + 4/(x - 1)</span>
</pre></div>
</div>
<p>Second example:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="n">apart_list</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span>
<span class="go">(-1,</span>
<span class="go">Poly(2/3, x, domain=&#39;QQ&#39;),</span>
<span class="go">[(Poly(_w - 2, _w, domain=&#39;ZZ&#39;), Lambda(_a, 2), Lambda(_a, -_a + x), 1)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="go">-2/3 - 2/(x - 2)</span>
</pre></div>
</div>
<p>Another example, showing symbolic parameters:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="n">apart_list</span><span class="p">(</span><span class="n">t</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">t</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span>
<span class="go">(1,</span>
<span class="go">Poly(0, x, domain=&#39;ZZ[t]&#39;),</span>
<span class="go">[(Poly(_w**2 + _w + t, _w, domain=&#39;ZZ[t]&#39;),</span>
<span class="go">Lambda(_a, -2*_a*t/(4*t - 1) - t/(4*t - 1)),</span>
<span class="go">Lambda(_a, -_a + x),</span>
<span class="go">1)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="go">RootSum(_w**2 + _w + t, Lambda(_a, (-2*_a*t/(4*t - 1) - t/(4*t - 1))/(-_a + x)))</span>
</pre></div>
</div>
<p>This example is taken from Bronstein’s original paper:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">36</span> <span class="o">/</span> <span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="n">apart_list</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span>
<span class="go">(1,</span>
<span class="go">Poly(0, x, domain=&#39;ZZ&#39;),</span>
<span class="go">[(Poly(_w - 2, _w, domain=&#39;ZZ&#39;), Lambda(_a, 4), Lambda(_a, -_a + x), 1),</span>
<span class="go">(Poly(_w**2 - 1, _w, domain=&#39;ZZ&#39;), Lambda(_a, -3*_a - 6), Lambda(_a, -_a + x), 2),</span>
<span class="go">(Poly(_w + 1, _w, domain=&#39;ZZ&#39;), Lambda(_a, -4), Lambda(_a, -_a + x), 1)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="go">-4/(x + 1) - 3/(x + 1)**2 - 9/(x - 1)**2 + 4/(x - 2)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.partfrac.apart" title="sympy.polys.partfrac.apart"><code class="xref py py-obj docutils literal notranslate"><span class="pre">apart</span></code></a>, <a class="reference internal" href="#sympy.polys.partfrac.assemble_partfrac_list" title="sympy.polys.partfrac.assemble_partfrac_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assemble_partfrac_list</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r665"><span class="brackets"><a class="fn-backref" href="#id26">R665</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#bronstein93" id="id25"><span>[Bronstein93]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.partfrac.assemble_partfrac_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.partfrac.</span></span><span class="sig-name descname"><span class="pre">assemble_partfrac_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">partial_list</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/partfrac.py#L419-L496"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.partfrac.assemble_partfrac_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Reassemble a full partial fraction decomposition
from a structured result obtained by the function <code class="docutils literal notranslate"><span class="pre">apart_list</span></code>.</p>
<p class="rubric">Examples</p>
<p>This example is taken from Bronstein’s original paper:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.partfrac</span> <span class="kn">import</span> <span class="n">apart_list</span><span class="p">,</span> <span class="n">assemble_partfrac_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">36</span> <span class="o">/</span> <span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="n">apart_list</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span>
<span class="go">(1,</span>
<span class="go">Poly(0, x, domain=&#39;ZZ&#39;),</span>
<span class="go">[(Poly(_w - 2, _w, domain=&#39;ZZ&#39;), Lambda(_a, 4), Lambda(_a, -_a + x), 1),</span>
<span class="go">(Poly(_w**2 - 1, _w, domain=&#39;ZZ&#39;), Lambda(_a, -3*_a - 6), Lambda(_a, -_a + x), 2),</span>
<span class="go">(Poly(_w + 1, _w, domain=&#39;ZZ&#39;), Lambda(_a, -4), Lambda(_a, -_a + x), 1)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="go">-4/(x + 1) - 3/(x + 1)**2 - 9/(x - 1)**2 + 4/(x - 2)</span>
</pre></div>
</div>
<p>If we happen to know some roots we can provide them easily inside the structure:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="n">apart_list</span><span class="p">(</span><span class="mi">2</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span>
<span class="go">(1,</span>
<span class="go">Poly(0, x, domain=&#39;ZZ&#39;),</span>
<span class="go">[(Poly(_w**2 - 2, _w, domain=&#39;ZZ&#39;),</span>
<span class="go">Lambda(_a, _a/2),</span>
<span class="go">Lambda(_a, -_a + x),</span>
<span class="go">1)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pfda</span> <span class="o">=</span> <span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfda</span>
<span class="go">RootSum(_w**2 - 2, Lambda(_a, _a/(-_a + x)))/2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pfda</span><span class="o">.</span><span class="n">doit</span><span class="p">()</span>
<span class="go">-sqrt(2)/(2*(x + sqrt(2))) + sqrt(2)/(2*(x - sqrt(2)))</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Dummy</span><span class="p">,</span> <span class="n">Poly</span><span class="p">,</span> <span class="n">Lambda</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Dummy</span><span class="p">(</span><span class="s2">&quot;a&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pfd</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">Poly</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;ZZ&#39;</span><span class="p">),</span> <span class="p">[([</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="n">Lambda</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">a</span><span class="o">/</span><span class="mi">2</span><span class="p">),</span> <span class="n">Lambda</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="o">-</span><span class="n">a</span> <span class="o">+</span> <span class="n">x</span><span class="p">),</span> <span class="mi">1</span><span class="p">)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">assemble_partfrac_list</span><span class="p">(</span><span class="n">pfd</span><span class="p">)</span>
<span class="go">-sqrt(2)/(2*(x + sqrt(2))) + sqrt(2)/(2*(x - sqrt(2)))</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.partfrac.apart" title="sympy.polys.partfrac.apart"><code class="xref py py-obj docutils literal notranslate"><span class="pre">apart</span></code></a>, <a class="reference internal" href="#sympy.polys.partfrac.apart_list" title="sympy.polys.partfrac.apart_list"><code class="xref py py-obj docutils literal notranslate"><span class="pre">apart_list</span></code></a></p>
</div>
</dd></dl>

</section>
<section id="dispersion-of-polynomials">
<h2>Dispersion of Polynomials<a class="headerlink" href="#dispersion-of-polynomials" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.dispersion.dispersionset">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.dispersion.</span></span><span class="sig-name descname"><span class="pre">dispersionset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">q</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/dispersion.py#L5-L127"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.dispersion.dispersionset" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the <em>dispersion set</em> of two polynomials.</p>
<p>For two polynomials <span class="math notranslate nohighlight">\(f(x)\)</span> and <span class="math notranslate nohighlight">\(g(x)\)</span> with <span class="math notranslate nohighlight">\(\deg f &gt; 0\)</span>
and <span class="math notranslate nohighlight">\(\deg g &gt; 0\)</span> the dispersion set <span class="math notranslate nohighlight">\(\operatorname{J}(f, g)\)</span> is defined as:</p>
<div class="math notranslate nohighlight">
\[\begin{split}\operatorname{J}(f, g)
&amp; := \{a \in \mathbb{N}_0 | \gcd(f(x), g(x+a)) \neq 1\} \\
&amp;  = \{a \in \mathbb{N}_0 | \deg \gcd(f(x), g(x+a)) \geq 1\}\end{split}\]</div>
<p>For a single polynomial one defines <span class="math notranslate nohighlight">\(\operatorname{J}(f) := \operatorname{J}(f, f)\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.dispersion</span> <span class="kn">import</span> <span class="n">dispersion</span><span class="p">,</span> <span class="n">dispersionset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<p>Dispersion set and dispersion of a simple polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">((</span><span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 6]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
<p>Note that the definition of the dispersion is not symmetric:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">shift</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2, 3, 4]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">)</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">)</span>
<span class="go">-oo</span>
</pre></div>
</div>
<p>Computing the dispersion also works over field extensions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[1, 4]</span>
</pre></div>
</div>
<p>We can even perform the computations for polynomials
having symbolic coefficients:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">a</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">8</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">a</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 1]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.dispersion.dispersion" title="sympy.polys.dispersion.dispersion"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dispersion</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r666"><span class="brackets"><a class="fn-backref" href="#id31">R666</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#manwright94" id="id27"><span>[ManWright94]</span></a></p>
</dd>
<dt class="label" id="r667"><span class="brackets"><a class="fn-backref" href="#id32">R667</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#koepf98" id="id28"><span>[Koepf98]</span></a></p>
</dd>
<dt class="label" id="r668"><span class="brackets"><a class="fn-backref" href="#id33">R668</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#abramov71" id="id29"><span>[Abramov71]</span></a></p>
</dd>
<dt class="label" id="r669"><span class="brackets"><a class="fn-backref" href="#id34">R669</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#man93" id="id30"><span>[Man93]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.dispersion.dispersion">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.dispersion.</span></span><span class="sig-name descname"><span class="pre">dispersion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">q</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/dispersion.py#L130-L212"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.dispersion.dispersion" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the <em>dispersion</em> of polynomials.</p>
<p>For two polynomials <span class="math notranslate nohighlight">\(f(x)\)</span> and <span class="math notranslate nohighlight">\(g(x)\)</span> with <span class="math notranslate nohighlight">\(\deg f &gt; 0\)</span>
and <span class="math notranslate nohighlight">\(\deg g &gt; 0\)</span> the dispersion <span class="math notranslate nohighlight">\(\operatorname{dis}(f, g)\)</span> is defined as:</p>
<div class="math notranslate nohighlight">
\[\begin{split}\operatorname{dis}(f, g)
&amp; := \max\{ J(f,g) \cup \{0\} \} \\
&amp;  = \max\{ \{a \in \mathbb{N} | \gcd(f(x), g(x+a)) \neq 1\} \cup \{0\} \}\end{split}\]</div>
<p>and for a single polynomial <span class="math notranslate nohighlight">\(\operatorname{dis}(f) := \operatorname{dis}(f, f)\)</span>.
Note that we make the definition <span class="math notranslate nohighlight">\(\max\{\} := -\infty\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.dispersion</span> <span class="kn">import</span> <span class="n">dispersion</span><span class="p">,</span> <span class="n">dispersionset</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<p>Dispersion set and dispersion of a simple polynomial:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">((</span><span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 6]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
<p>Note that the definition of the dispersion is not symmetric:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">shift</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2, 3, 4]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">)</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dispersion</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">)</span>
<span class="go">-oo</span>
</pre></div>
</div>
<p>The maximum of an empty set is defined to be <span class="math notranslate nohighlight">\(-\infty\)</span>
as seen in this example.</p>
<p>Computing the dispersion also works over field extensions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="mi">2</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="s1">&#39;QQ&lt;sqrt(5)&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">,</span> <span class="n">gp</span><span class="p">))</span>
<span class="go">[2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">gp</span><span class="p">,</span> <span class="n">fp</span><span class="p">))</span>
<span class="go">[1, 4]</span>
</pre></div>
</div>
<p>We can even perform the computations for polynomials
having symbolic coefficients:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">a</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fp</span> <span class="o">=</span> <span class="n">poly</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">8</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="n">a</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">a</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">dispersionset</span><span class="p">(</span><span class="n">fp</span><span class="p">))</span>
<span class="go">[0, 1]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.dispersion.dispersionset" title="sympy.polys.dispersion.dispersionset"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dispersionset</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r670"><span class="brackets"><a class="fn-backref" href="#id39">R670</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#manwright94" id="id35"><span>[ManWright94]</span></a></p>
</dd>
<dt class="label" id="r671"><span class="brackets"><a class="fn-backref" href="#id40">R671</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#koepf98" id="id36"><span>[Koepf98]</span></a></p>
</dd>
<dt class="label" id="r672"><span class="brackets"><a class="fn-backref" href="#id41">R672</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#abramov71" id="id37"><span>[Abramov71]</span></a></p>
</dd>
<dt class="label" id="r673"><span class="brackets"><a class="fn-backref" href="#id42">R673</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#man93" id="id38"><span>[Man93]</span></a></p>
</dd>
</dl>
</dd></dl>

</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Polynomials Manipulation Module Reference</a><ul>
<li><a class="reference internal" href="#basic-polynomial-manipulation-functions">Basic polynomial manipulation functions</a></li>
<li><a class="reference internal" href="#extra-polynomial-manipulation-functions">Extra polynomial manipulation functions</a></li>
<li><a class="reference internal" href="#domain-constructors">Domain constructors</a></li>
<li><a class="reference internal" href="#algebraic-number-fields">Algebraic number fields</a></li>
<li><a class="reference internal" href="#monomials-encoded-as-tuples">Monomials encoded as tuples</a></li>
<li><a class="reference internal" href="#orderings-of-monomials">Orderings of monomials</a></li>
<li><a class="reference internal" href="#formal-manipulation-of-roots-of-polynomials">Formal manipulation of roots of polynomials</a></li>
<li><a class="reference internal" href="#symbolic-root-finding-algorithms">Symbolic root-finding algorithms</a></li>
<li><a class="reference internal" href="#special-polynomials">Special polynomials</a></li>
<li><a class="reference internal" href="#orthogonal-polynomials">Orthogonal polynomials</a></li>
<li><a class="reference internal" href="#manipulation-of-rational-functions">Manipulation of rational functions</a></li>
<li><a class="reference internal" href="#partial-fraction-decomposition">Partial fraction decomposition</a></li>
<li><a class="reference internal" href="#dispersion-of-polynomials">Dispersion of Polynomials</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="wester.html"
                        title="previous chapter">Examples from Wester’s Article</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="agca.html"
                        title="next chapter">AGCA - Algebraic Geometry and Commutative Algebra Module</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/polys/reference.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="agca.html" title="AGCA - Algebraic Geometry and Commutative Algebra Module"
             >next</a> |</li>
        <li class="right" >
          <a href="wester.html" title="Examples from Wester’s Article"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Polynomial Manipulation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Polynomials Manipulation Module Reference</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/polys/reference.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:59 GMT -->
</html>